Circuit Components and Sensors: For Microcontroller Programming
Circuit Components and Sensors: For Microcontroller Programming
Essential components needed for microcontroller circuits include LEDs, resistors, batteries, and jumper wires. These
components work together to create functional electronic projects.
LEDs Resistors
Convert electrical energy to light Limit current flow in circuits
Longer leg is positive(anode) Measured in ohms (Ω) Color
Require current-limiting resistor bands indicate value
Batteries
Provide power to the circuit
Common types: AA, AAA, 9V
Check voltage requirements
Introduction to Sensors
● Sensors are devices that detect changes in the
environment and convert them into electrical signals
on/off states
Max
Grade 7
MODULES
• In MicroPython, a module is a file that
contains Python code, including functions,
classes, and variables
• Modules help in organizing code and making
it reusable
• You can import a module into your
MicroPython program to use its functions and
classes.
Library
• A library is a collection of modules that
provide additional functionality for your
projects
• Libraries extend the capabilities of your code
by providing pre-written functions and classes.
• MicroPython includes several built-in libraries
you can use.
machine library— functions related to
the hardware
• contains specific functions related to the
hardware on a particular board
• Most functions in this module allow to
achieve direct and unrestricted access to and
control of hardware blocks on a system (like
CPU, timers, buses, etc.)
utime library– time related functions
Line-by-Line Breakdown
• Purpose: Another blank line to separate the imports from the main code
Line 7: led=machine.Pin(25,machine.Pin.OUT)
• Purpose: Separates the "LED on" section from the "LED off" section