0% found this document useful (0 votes)
6 views17 pages

Microcontrollers

ALL ABOUT MICROCONTROLLERS ALSO NEED TO BE UPLOADED

Uploaded by

ahmadhmubashar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views17 pages

Microcontrollers

ALL ABOUT MICROCONTROLLERS ALSO NEED TO BE UPLOADED

Uploaded by

ahmadhmubashar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Microcontrollers

Microcontrollers are small computers that control different devices. Let's look at some popular
microcontrollers, their pin details (including interrupt pins), communication protocols, and their
use cases.

Arduino Uno
The Arduino Uno is the most commonly used microcontroller board, ideal for beginners.
Total Pins: 28 I/O pins (14 digital + 6 analog + power and special function pins).

Digital Pins: 14 pins (D0 to D13).

• These can be used as input or output.


• D0 and D1 are also used for Serial Communication (RX and TX).

Analog Pins: 6 pins (A0 to A5).

• These read analog signals (0 to 5V).

Interrupt Pins: `D2` and `D3` can be used for external interrupts
Special Pins:

• 5V and GND: Power supply for components and sensors.


• AREF (Analog Reference Pin): Used to set a reference voltage for the analog input.
• PWM Pins: 6 pins (D3, D5, D6, D9, D10, D11) are PWM-capable (for dimming LEDs,
controlling motors).
• ICSP Header: Used for In-Circuit Serial Programming (to burn bootloader).

ESP8266
The ESP8266 is a popular microcontroller with built-in Wi-Fi. It is used in many IoT
applications.

• Total Pins: 17 I/O pins.


• Digital Pins: 11 pins (D0 to D8, RX, TX).
o TX and RX pins are used for Serial Communication.
• Analog Pin: 1 pin (A0).
o It can only read up to 1V analog input.
• Special Pins:
o GPIO Pins: All digital pins are General Purpose I/O pins that can be used for
multiple purposes.
o PWM: Pins can be used for PWM to control motors or dim LEDs.
o Wi-Fi and Networking: Its main feature is built-in Wi-Fi for wireless
communication.
o Power Pins: 3.3V and GND pins are used to power the board and connected
sensors.
o Interrupt Pins: Any GPIO pin can be configured as an interrupt.

ESP32
The ESP32 is a powerful microcontroller that features both Wi-Fi and Bluetooth connectivity.
It has more capabilities than the ESP8266.

• Total Pins: 38 I/O pins.


• Digital Pins: 34 GPIO pins (General Purpose Input/Output).
o Can be used for input/output, PWM, I2C, SPI, and UART.
• Analog Pins: 18 ADC (Analog-to-Digital Converter) pins (32 channels).
o Supports analog input with a range of 0 to 3.3V.
o 2 DAC (Digital-to-Analog Converter) pins can output analog signals.
• Special Pins:
o Capacitive Touch: The ESP32 has 10 pins that can be used as capacitive touch
sensors.
o PWM: Any GPIO pin can generate PWM signals.
o Wi-Fi and Bluetooth: Built-in support for wireless communication.
o Power Pins: 3.3V and GND pins, and other power-related pins like EN (enable),
and Vin (for external power supply).
o Interrupt Pins: Any GPIO pin can be used for external interrupts.

STM32 (Blue Pill)


The STM32 family is a popular series of microcontrollers used for advanced applications. The
STM32F103C8 (commonly called the "Blue Pill") is a popular low-cost model.

• Total Pins: 37 I/O pins.


• Digital Pins: 37 GPIO pins.
o Supports multiple communication protocols like I2C, SPI, UART, etc.
• Analog Pins: 10 pins (A0 to A9).
o They can read analog input between 0 and 3.3V.
• Special Pins:
o PWM Pins: 15 GPIO pins can be used for PWM.
o USB Pins: It has built-in USB support, so you can connect it directly to a
computer.
o Power Pins: 3.3V and GND pins for power.
o Reset Pin: Used to reset the microcontroller.
o Boot Pins: Two pins used to select the boot mode (flash or bootloader).
o Interrupt Pins: Any GPIO pin can be configured as an interrupt.
Raspberry Pi Pico
The Raspberry Pi Pico is a microcontroller based on the RP2040 chip, which is powerful and
affordable.

• Total Pins: 40 pins (26 I/O pins).


• Digital Pins: 26 GPIO pins.
o Supports digital input/output, I2C, SPI, UART.
• Analog Pins: 3 pins (ADC0 to ADC2).
o Can read analog values up to 3.3V.
• Special Pins:
o PWM Pins: All GPIO pins can be used for PWM (hardware-based PWM).
o Power Pins: 3.3V, GND, and VSYS (for external power source).
o USB Pins: The board has a built-in micro USB connector for power and
communication.
o Debug Pins: 3 pins are used for debugging via the SWD interface.
o Interrupt Pins: Any GPIO pin can be used for interrupts.

ATmega328P
The ATmega328P is the microcontroller chip used in the Arduino Uno, but it is also available
as a standalone chip that you can use in custom circuits.

• Total Pins: 28 pins.


• Digital Pins: 14 digital pins (D0 to D13).
o D0 and D1 are used for UART serial communication.
• Analog Pins: 6 analog pins (A0 to A5).
o Reads analog values between 0 and 5V.
• Special Pins:
o PWM Pins: 6 pins can be used for PWM output (D3, D5, D6, D9, D10, D11).
o Oscillator Pins: Two pins are used for an external clock source (XTAL1,
XTAL2).
o Power Pins: VCC (5V) and GND.
o Reset Pin: Used to reset the microcontroller.
o ICSP Pins: In-Circuit Serial Programming pins for programming the chip.

Interrupt Pins and Their Use


Interrupts allow a microcontroller to stop what it's doing and respond to an urgent event. Instead
of constantly checking a sensor (polling), the microcontroller can handle other tasks and only
react when an event occurs.
External Interrupt Pins:
• Arduino Uno: Pins `D2` and `D3`.
• ESP8266/ESP32: Any GPIO pin can be used for interrupts.
• STM32: Any GPIO pin.
• Raspberry Pi Pico: Any GPIO pin.

How to Use Interrupts (Arduino Example):


void setup() {
pinMode(2, INPUT); // Set pin 2 as input for the interrupt
attachInterrupt(digitalPinToInterrupt(2), handleInterrupt, RISING);
// Trigger on rising edge
}

void loop() {
// Your main code here
}

void handleInterrupt() {
// Code to run when interrupt occurs
}

Common Interrupt Modes:


• RISING: Interrupt triggers when the pin goes from LOW to HIGH.
• FALLING: Interrupt triggers when the pin goes from HIGH to LOW.
• CHANGE: Interrupt triggers on any change in pin state.
Communication Protocols
Microcontrollers use communication protocols to exchange data with sensors, modules, and
other devices.
• UART (Universal Asynchronous Receiver-Transmitter)
• Pins: `TX` (Transmit) and `RX` (Receive).
• Purpose: UART is used for serial communication between devices (e.g., microcontroller
and PC or between microcontrollers).
How to Use:
• Connect `TX` of one device to `RX` of another.
• Set the baud rate (communication speed) in both devices.
Arduino Example:
void setup() {
[Link](9600); // Start serial communication at 9600 baud rate
}

void loop() {
[Link]("Hello, World!"); // Send data over UART
delay(1000);
}

I2C (Inter-Integrated Circuit)


• Pins: `SDA` (Data line), `SCL` (Clock line).
• Purpose: Allows communication with multiple devices using just two wires. Each device
has a unique address.
How to Use:
• Connect `SDA` to `SDA` and `SCL` to `SCL`.
• Use the device’s address to send/receive data.
Arduino I2C Example:
#include <Wire.h>

void setup() {
[Link](); // Initialize I2C
}

void loop() {
[Link](0x68);
// Begin communication with device at address 0x68
[Link](0x00); // Send data
[Link]();
delay(1000);
}

SPI (Serial Peripheral Interface)


• Pins: `MOSI` (Master Out Slave In), `MISO` (Master In Slave Out), `SCK` (Clock), `SS`
(Slave Select).
• Purpose: Used for fast data transfer between a master (microcontroller) and multiple
slaves (sensors, displays).
How to Use:
• Connect `MOSI`, `MISO`, `SCK`, and `SS` to corresponding pins.
• Configure the SPI clock speed and mode.
Sensors: Categories, Functions, and Technical Specifications
Temperature and Humidity Sensors
These sensors measure temperature, humidity, or both. They're used in environmental
monitoring, HVAC systems, weather stations, etc.

Light Sensors
These sensors detect light intensity or color. They're used in robotics, automatic lighting,
photography, and environmental monitoring.
Distance and Proximity Sensors
These sensors measure the distance of an object from the sensor. They are used in robotics,
object detection, obstacle avoidance, and security systems.

Motion and Vibration Sensors


These sensors detect motion, movement, or vibration and are used in security systems, robotics,
and wearable technology.
Gas and Air Quality Sensors
These sensors measure air quality, including gases like CO2, CO, methane, and volatile organic
compounds (VOCs). They are essential for environmental monitoring, industrial safety, and
home automation.

Pressure and Force Sensors


These sensors detect force or pressure and are used in applications like robotics, wearables,
weather stations, and touch-sensitive devices.
Sound and Vibration Sensors
These sensors detect sound or vibrations and are used in noise monitoring, automation, and
security systems.

Environmental Sensors
Environmental sensors monitor aspects like UV radiation, soil moisture, and other ecological
conditions.
Motor Drivers
Motor drivers are used to control DC motors, stepper motors, and servo motors. Here are the
popular motor drivers and their characteristics:

DC Motor Drivers
DC motor drivers control the speed and direction of DC motors. They typically use PWM
signals to vary motor speed.

Stepper Motor Drivers


Stepper motor drivers control stepper motors, which require precise position control.

Servo Motor Drivers


Servo motor drivers control servo motors, typically using PWM signals to set the motor
position.
Conclusion: Universal Characteristics for Sensors and Drivers
• Voltage: Most sensors and motor drivers work on 3.3V or 5V. Ensure the microcontroller
voltage matches.
• Communication Protocols: Sensors typically use analog, digital, I2C, SPI, or UART.
Motor drivers use PWM for speed/position control.
• Power: Some sensors are low-power (few mA), while others like motors may require
higher current (use motor drivers to handle power requirements).

Automation Projects

Automatic Sorting Machine Using ESP32 CAM and Conveyor Belt


Objective:
Automatically sort objects based on color or shape using image recognition with the ESP32
CAM and a conveyor belt system.

Components Needed:

• ESP32 CAM Module


• Servo Motors (for sorting mechanism)
• DC Motor (for conveyor belt)
• Motor Driver (L298N)
• Jumper Wires
• Power Supply (5V/12V)
• Webcam-compatible Power Supply (for ESP32 CAM)
• Object containers (to collect sorted items)
• Conveyor belt (DIY or purchased)
• OpenCV or similar image processing software (optional for PC)

How to Do:

1. Conveyor Belt Setup: Build or purchase a small conveyor belt. Attach a DC motor to
drive the belt using the L298N motor driver, controlled by the ESP32 CAM.
2. Camera Integration: Mount the ESP32 CAM above the conveyor belt. The camera will
capture images of objects as they move along the belt.
3. Image Processing: Program the ESP32 CAM to recognize different colors or shapes using
basic image recognition algorithms. You can use the ESP32's onboard processing power
or send data to a server for advanced image processing using OpenCV.
4. Sorting Mechanism: Use servos attached to the edge of the conveyor belt to push
objects into different bins based on the identified color or shape.
5. Testing and Calibration: Test with different objects, calibrating the speed of the
conveyor and the response of the sorting mechanism.

Home Cleaning RC Robot


Objective:
Design a remote-controlled (RC) robot for home cleaning, equipped with brushes, motors, and
wireless control.

Components Needed:

• Arduino UNO or ESP32 (for Wi-Fi control)


• L298N Motor Driver (for DC motors)
• DC Motors with wheels
• Servo Motor (for steering or special cleaning features)
• Sweeping brush (attachable or DIY)
• Ultrasonic Sensor (for obstacle detection)
• Remote Control (RF module or smartphone app with ESP32)
• LiPo Battery Pack
• Power Switch
• Chassis (can be DIY or purchased)
• Buzzer for alerts (optional)

How to Do:

1. Chassis Design: Build a robot chassis that includes wheels, a mounting space for the
cleaning brush, and space for the electronic components. Attach the DC motors to the
wheels.
2. Motor and Steering Control: Use an L298N motor driver to control the motors' speed
and direction. If you want better control, add a servo motor for steering the wheels or
the cleaning mechanism.
3. Cleaning Mechanism: Attach a cleaning brush at the front or bottom of the robot. You
can use rotating brushes (like a vacuum cleaner) or fixed ones.
4. Obstacle Detection: Use ultrasonic sensors to detect obstacles and avoid collisions. The
sensor data can be used to stop or steer the robot automatically.
5. RC Control: If using Arduino, set up an RF module to allow wireless remote control. For
ESP32, use Wi-Fi to control the robot through a smartphone app or web interface.
6. Power: Power the robot using a rechargeable LiPo battery, making sure the motors and
control board have separate power regulation if needed.
Automatic Plant Watering System
Objective:
Automatically water plants based on soil moisture levels, making it suitable for gardens or
indoor plants.

Components Needed:

• Arduino UNO or ESP8266 (for wireless control)


• Soil Moisture Sensor
• Water Pump (5V or 12V)
• Relay Module
• Jumper Wires
• Power Supply (5V/12V)
• Tubing (to carry water to the plants)
• Water reservoir

How to Do:

1. Soil Moisture Monitoring: Connect the soil moisture sensor to the analog input of the
Arduino or ESP8266. It will continuously monitor the soil moisture level.
2. Pump Control: Connect the water pump to a relay module, which acts as a switch to
turn the pump ON or OFF based on the moisture sensor’s readings.
3. Programming: Write code that checks the moisture sensor's values. If the soil is dry, the
relay triggers the water pump to irrigate the plants.
4. Wireless Control (Optional): If you’re using an ESP8266, you can add a web interface to
monitor and control the irrigation system remotely.
5. Water Delivery: Place the water reservoir nearby and set up the tubing system so the
pump can deliver water to your plants.

Smart Parking System Using Ultrasonic Sensor


Objective:
Design a parking assistant that indicates whether a parking spot is available or occupied using
an ultrasonic sensor.

Components Needed:

• Arduino UNO
• Ultrasonic Sensor (HC-SR04)
• LEDs (Red and Green)
• Buzzer (optional, for an audible alert)
• Jumper Wires
• Power Supply (5V for Arduino and sensors)

How to Do:

1. Sensor Placement: Mount the ultrasonic sensor at the parking spot to detect the
distance between the sensor and the vehicle. Connect the sensor to the Arduino using
the Trig and Echo pins.
2. LED and Buzzer Setup: Use green and red LEDs to indicate parking spot availability.
Green indicates the spot is empty, while red means the spot is occupied. The buzzer can
provide an additional audio alert when a car approaches.
3. Programming: Write a program that reads the distance from the ultrasonic sensor. If the
distance is within a certain range (e.g., less than 20 cm), it means a car is parked, and
the red LED will turn on.
4. Indication System: Use the green LED to show an available spot and the red LED (and
optionally, the buzzer) to indicate when a car occupies the space.
5. Testing: Simulate a parking scenario by placing objects at various distances to test how
accurately the sensor detects the car and how well the LEDs and buzzer respond.

Smart Pet Feeder Using Servo Motor and RTC (Real-Time Clock)
Objective:
Create an automated pet feeder that dispenses food at preset times during the day using a real-
time clock (RTC) module for scheduling.

Components Needed:

• Arduino UNO
• Servo Motor (for controlling food dispenser)
• RTC Module (e.g., DS3231)
• Jumper Wires
• Food Container with a dispensing mechanism (can be DIY)
• LCD Display (optional, to show feeding times)
• Power Supply (5V for Arduino and servo)

How to Do:

1. RTC Setup: Connect the DS3231 RTC module to the Arduino to keep track of the time.
The RTC will be used to trigger feeding times.
2. Servo Control: Attach the servo motor to the food dispenser mechanism. The servo will
rotate at specific times to open the dispenser and allow food to be released.
3. Programming: Program the Arduino to read the time from the RTC and activate the
servo motor at preset feeding times (e.g., 8 AM, 12 PM, 6 PM). After a short delay (e.g.,
10 seconds), the servo will return to its original position to stop the food from
dispensing.
4. Display (Optional): Add an LCD display to show the current time and the next feeding
time for user convenience.
5. Testing: Test the feeder with your pet’s food to ensure the servo operates smoothly and
that the food is dispensed correctly at the scheduled times.

Fire Fighter Robot


Objective:
Develop an autonomous robot capable of detecting fires, navigating through an environment,
and extinguishing small fires. The robot will assist in emergency situations by providing early
intervention and support.

Components Needed:

• Microcontroller: Arduino UNO, ESP32, or Raspberry Pi (for control)


• Fire Detection Sensors: Infrared (IR) sensors or thermal cameras
• Movement: DC motors with wheels or tracks, motor driver (e.g., L298N)
• Extinguishing Mechanism: Water pump or CO2 canister
• Camera: For real-time video feed (optional)
• GPS Module: For navigation (optional, for more complex environments)
• Battery Pack: To power the robot
• Relay Module: To control the extinguishing mechanism
• Wireless Module: For remote control or data transmission (e.g., Wi-Fi, Bluetooth)
• Power Supply: 5V/12V depending on components

How to Do:

1. Fire Detection:
o Sensors: Use infrared sensors or a thermal camera to detect heat signatures
indicative of a fire. Infrared sensors are more affordable, but thermal cameras
provide more detailed data.
o Integration: Connect the sensors to the microcontroller to continuously monitor
the environment for signs of fire.
2. Navigation and Movement:
o Movement Mechanism: Use DC motors with wheels or tracks to navigate the
robot through obstacles. Motor drivers will control the direction and speed of the
motors.
o Obstacle Avoidance: Implement additional sensors (like ultrasonic sensors) to
detect and avoid obstacles.
3. Extinguishing Mechanism:
Water Pump: A small water pump can be used to spray water onto the fire.
o
Ensure it is capable of being controlled by the microcontroller via a relay.
o CO2 Canister: For a more advanced system, a CO2 canister can be used to
extinguish fires. Integrate it with the relay module to activate when needed.
4. Camera System (Optional):
oReal-time Feed: Add a camera to provide real-time video feed to a remote control
station. This can help operators assess the situation and guide the robot.
5. Navigation and Control:
oRemote Control: Use a wireless module (Wi-Fi or Bluetooth) to control the robot
remotely. This is particularly useful for steering and making decisions based on
real-time data.
o Autonomous Navigation: Implement basic algorithms for autonomous
navigation, using sensor data to follow paths and avoid obstacles.
6. Programming:
o Sensor Integration: Write code to read data from fire detection sensors and
decide when to activate the extinguishing mechanism.
o Movement Control: Program the robot’s movement, obstacle avoidance, and
response to fire detection.
o Extinguishing Logic: Implement logic to control the extinguishing mechanism
based on fire detection.
7. Testing:
o Simulation: Test the robot in a controlled environment with simulated fire
conditions to ensure it can detect and extinguish fires effectively.
o Field Testing: Conduct tests in various scenarios to refine the robot’s navigation,
fire detection, and extinguishing capabilities.

Additional Considerations:

• Safety: Ensure that the robot operates safely, with fail-safes to prevent accidents.
• Durability: Design the robot to withstand high temperatures and potentially harsh
conditions.
• Scalability: Consider how the robot can be scaled or adapted for different fire-fighting
tasks or environments.

You might also like