Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. #define F_CPU 16000000L
  2. #include <avr/io.h>
  3. #include <util/delay.h>
  4. #include <avr/interrupt.h>
  5.  
  6. volatile int8_t counter=-1;
  7. volatile uint8_t seg[4]={0b01001100, 0b01000001, 0b01000011, 0b01001000};
  8.  
  9. ISR(TIMER0_OVF_vect)
  10.     {
  11.     PORTB=255;
  12.     counter++;
  13.     if (counter==4) counter=0;
  14.     PORTA=seg[counter];
  15.     PORTB=~_BV(counter);
  16.     }
  17.  
  18. void main(void)
  19.     {
  20.     DDRA=255;
  21.     DDRB=0x0F;
  22.     sei();
  23.     TIMSK|=_BV(TOIE0);
  24.     TCCR0|=_BV(CS00)|_BV(CS01);
  25.  
  26.     while (1)
  27.         {
  28.         }
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement