Skip to main content

02 Experiment

Hello LED – Flash LED at a rate such that the LED appears always on. Estimate the onset of the rate when the LED appears to stay on

Source and description

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

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

/*Change the value of BLINK_DELAY_MS such that the LED appears always on*/
#define BLINK_DELAY_MS 10

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);
}
}