Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.36 KB | None | 0 0
  1. #include <avr/io.h>
  2. #include <avr/interrupt.h>
  3.  
  4. uint8_t i = 0;
  5. uint8_t links = 0;
  6.  
  7. ISR(TIMER0_OVF_vect)
  8. {
  9.  
  10.     if(!i) {
  11.         links = 1;
  12.     } else if ( i == 8 ) {
  13.         links = 0;
  14.     }
  15.  
  16.     if (links) {
  17.         PORTB = ~(1 << i++);
  18.     }
  19.     else {
  20.         PORTB = ~(1 << --i);
  21.     }
  22. }
  23.  
  24. int main(void)
  25. {
  26.     DDRB=0xFF;
  27.     PORTB=0xFF;
  28.     TCCR0=0x05;
  29.     TIMSK=0x01;
  30.     sei();
  31.     while(1);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement