-
-
Save isma44/cbae84a1d8fa875bdc0d to your computer and use it in GitHub Desktop.
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
#define LEDPORT PORTD | |
#define LEDBIT PD6 | |
#define LEDDDR DDRD | |
#include <avr/io.h> | |
int main (void) | |
{ | |
LEDDDR |= (1 << LEDBIT); // set LED pin as an output | |
TCCR1B |= ((1 << CS10) | (1 << CS11)); // configure timer prescaling | |
for(;;) | |
{ | |
if (TCNT1 >= 15624) // when the timer counts one second | |
{ | |
LEDPORT ^= (1 << LEDBIT); // toggle the LED | |
TCNT1 = 0; // and reset the timer value | |
} | |
} | |
return 0; // the program executed successfully | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment