Aim:
Light Emitting Diodes (LED) is the most commonly used components,
usually for displaying pins digital states. Typical uses of LEDs include
alarm devices, timers and confirmation of user input such as a mouse
click or keystroke. The main aim of this project is how to interface a
single LED to atmega-8 microcontroller.
Description:
Interfacing LED:
Fig. 1 shows how to interface the LED to microcontroller. As you can see the Cathode is connected through a resistor to GND & the Anoode is connected to the Microcontroller pin. So when the Port Pin is HIGH the LED is ON & when the Port Pin is LOW the LED is turned OFF.
We now want to flash a LED in atmega8 board. It works by turning ON a LED & then turning it OFF & then looping back to START. However the operating speed of microcontroller is very high so the flashing frequency will also be very fast to be detected by human eye.
The atmega8 board has eight numbers of point LEDs, connected with I/O Port lines to make port pins high.
Pin Assignment with atmega8
Point LEDs | Atmega 8 direction | Atmega 8 Lines | LED Selection | Connections | |
DIGITAL OUTPUTS | LED.0 | DDRx=0x01 | PORTx=0x01 | Connect Any one PORT from
PORTB, PORTC, PORTD
| |
LED.1 | DDRx=0x02 | PORTx=0x02 | |||
LED.2 | DDRx=0x04 | PORTx=0x04 | |||
LED.3 | DDRx=0x08 | PORTx=0x08 | |||
LED.4 | DDRx=0x10 | PORTx=0x10 | |||
LED.5 | DDRx=0x20 | PORTx=0x20 | |||
LED.6 | DDRx=0x40 | PORTx=0x40 | |||
LED.7 | DDRx=0x80 | PORTx=0x80 |
Block Diagram
Schematic:
Code:
// *********************************************************** // Project: Interfacing Single LED to atmega8 // Author: Code Bloges // Module description: Operate single LED // *********************************************************** #define F_CPU 8000000UL #include <avr/io.h> #include<util/delay.h> int main(void) { DDRB=0x01; while(1) { PORTB=0x01; } }
Downloads:
The code was compiled in Atmel Studio 6 and simulation was made in Proteus v7.7.
To download code and proteus simulation click here.
Further Reading suggestions:
You may also like,
- Interfacing keypad with AVR
- nterfacing DAC with AVR
- Interfacing with UART of AVR controller
- Interfacing SPI communication with AVR
- AVR Displaying Custom Characters on LCD
- AVR Graphical LCD
- RTC interfacing using I2C in AVR
- Interfacing ultrasonic sensor with AVR
- Interfacing GPS Modu with AVR
- Interfacing GSM Module with AVR
- Interfacing PWM in AVR
- Interfacing ADC with AVR
- Scrolling string on LCD using AVR
- Interfacing keypad with AVR
- nterfacing DAC with AVR
- Interfacing with UART of AVR controller
- Interfacing SPI communication with AVR
- AVR Displaying Custom Characters on LCD
- AVR Graphical LCD
- RTC interfacing using I2C in AVR
- Interfacing ultrasonic sensor with AVR
- Interfacing GPS Modu with AVR
- Interfacing GSM Module with AVR
- Interfacing PWM in AVR
- Interfacing ADC with AVR
- Scrolling string on LCD using AVR
No comments:
Post a Comment