Advertisement
Guest User

atmega328p

a guest
Nov 5th, 2015
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1. #include <avr/io.h>
  2. #include <avr/interrupt.h>
  3.  
  4. volatile uint16_t counter;
  5.  
  6. int main(void)
  7. {
  8.     DDRB |= (1<<PB5);
  9.  
  10.     TCCR0B |= (1 << CS00) | (1 << CS01);
  11.     TCNT0 = 0;
  12.     TIMSK0 |= (1<<TOIE0);
  13.     sei();                          // enable interrupts
  14.  
  15.  
  16.     while (1)
  17.     {
  18.         if (TCNT0 >= 100)
  19.         {
  20.             PORTB ^= _BV(PB5);
  21.             TCNT0 = 0;            // reset counter
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement