Skip to content

Instantly share code, notes, and snippets.

@isma44
Forked from holachek/main.c
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isma44/cbae84a1d8fa875bdc0d to your computer and use it in GitHub Desktop.
Save isma44/cbae84a1d8fa875bdc0d to your computer and use it in GitHub Desktop.
#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