LED Blinking
LED Blinking
Microcontroller Lab
LED blinking using ATmega32
Project done by
1. 22EL002: Dhruv Gandhi
2. 22El004: Anirudh Chagli
3. 22EL006: Yash Bhoi
4. 22EL011: Rudren Patadia
5. 22EL012: Yash Pandey
6. 22EL045: Naveen Shah
Aim: Blinking LED lights using ATmega32
Description of Components
ATmega32: The high-performance, low-power Microchip 8-bit
AVR® RISC-based microcontroller combines 32 KB ISP flash
memory with read-while-write capabilities, 1 KB EEPROM, 2
KB SRAM, 54/69 general purpose I/O lines, 32 general
purpose working registers, a JTAG interface for boundary-scan
and on-chip debugging/programming, three flexible
timer/counters with compare modes, internal and external
interrupts, serial programmable USART, a universal serial
interface (USI) with start condition detector, an 8-channel 10-
bit A/D converter, programmable watchdog timer with
internal oscillator, SPI serial port, and five software selectable
power saving modes. The device operates between 1.8-5.5
volts.
LED
An LED, or Light Emitting Diode, is a semiconductor device
that emits light when an electric current passes through it.
LEDs are widely used in various applications due to their
efficiency, longevity, and versatility.
To prevent damage to the LED and ensure proper operation, a
current-limiting resistor is used in series with the LED. The
value of this resistor is calculated based on the supply
voltage, the forward voltage of the LED, and the desired
current using Ohm's Law.
Advantages of LEDs
Energy Efficiency, Long Lifespan, Durability, Compact Size, Fast
Switching.
Capacitor
Capacitors are passive electronic components that store
electrical energy in an electric field. They are widely used in
electronic circuits for various purposes, such as filtering,
bypassing, coupling, and energy storage.
Electrolytic capacitors are polarized capacitors, which means
they have a positive (anode) and a negative (cathode)
terminal. They typically have a much higher capacitance per
unit volume compared to other types of capacitors. They are
usually cylindrical and are often marked with the capacitance
value and the working voltage.
Ceramic capacitors are non-polarized capacitors, which
means they can be connected in any direction. They are
made from a ceramic material as the dielectric and metal
layers as the electrodes. They are usually small and come in
various shapes, such as disc, multilayer, and surface mount.
#include <avr/io.h>
#include <util/delay.h>
int main(void) {
// Set LED_PIN as an output
DDRB |= (1 << LED_PIN);
while (1) {
// Turn LED on
PORTB |= (1 << LED_PIN);
delay_ms_custom(delay_time);
// Turn LED off
PORTB &= ~(1 << LED_PIN);
delay_ms_custom(delay_time);
return 0;
}
Applications
• Status indication: LEDs can be used to indicate different
system states like power on, processing ongoing, or
error conditions.
• Simple user interaction: Blinking LEDs can be used to
create basic user interactions, like acknowledging
button presses or providing feedback during operations.
• Timing and pulse generation: The techniques used to
create delays for blinking can be adapted for precise
timing control in applications like motor control or signal
generation.
• PWM (Pulse Width Modulation): By rapidly turning the
LED on and off, you can control its perceived brightness.
This technique, called PWM, is used to control light
intensity in various applications like dimming LEDs or
driving motors.
• Data transmission: Blinking LEDs in a specific pattern
can be used to transmit data in a simple communication
system.
Conclusion
In conclusion, blinking an LED with an ATmega32
microcontroller may seem like a simple task, but it offers
significant advantages for those venturing into
embedded systems development. It serves as It
introduces essential concepts like I/O pin configuration,
program structure, and often, timers.