Skip to main content

01 Experiment

Flash led at observable rate

Source and description

http://sincgrid.in/avr-tutorials/avr-tutorial-experiment-1/

http://sincgrid.in/avr-tutorials/avr-tutorial-experiment-1/
#include <avr/io.h>
#include <util/delay.h>

#define BLINK_DELAY_MS 100

int main (void)
{
/* NANO pin 13 (DDB5), set pin 5 of PORTB for output*/
DDRB |= _BV(DDB5);

while(1) {
/* NANO pin 13 (DDB5), set pin 5 high to turn led on */
PORTB |= _BV(PORTB5);
_delay_ms(BLINK_DELAY_MS);

/* NANO pin 13 (DDB5), set pin 5 low to turn led off */
PORTB &= ~_BV(PORTB5);
_delay_ms(BLINK_DELAY_MS);
}
}