Blinky with Starter AVR Revision as of 17:36, 5 April 2016 by Vaibhav Katkar (Talk | contribs)
After setting up starter AVR board, we will start with simple LED blinking experiment. Two user LED's are provided on starter AVR board, we will use same for this experiment.
Basic
On starter AVR board LED's are connected to PD4 and PD5. We are using one connected to PB5 in this example. I am using Atmel Studio to write the code. To know about how to do setting and create a project in Atmel Studio, look at our AVR Hardware and Software Setup tutorial. After generating the hex file, look at our Setting Up Starter AVR tutorial to flash the hex file to the board.
Hookup
Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <avr/io.h> | |
#include <util/delay.h> | |
#define LED 5 | |
int main() | |
{ | |
DDRD = (1<<LED); // Configure PORTD5 as output | |
while(1) | |
{ | |
PORTD = (1<<LED); // Turn ON Led connected to PORTD5 | |
_delay_ms(1000); // Wait for some time | |
PORTD = (0<<LED); // Turn OFF Led connected to PORTD5 | |
_delay_ms(1000); // Wait for some time | |
} | |
return 0; | |
} |
Demo
Downloads