Advertisement
ktostam450

[ARDUINO] lampka migająca 8Hz

Apr 25th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. #include <avr/io.h>
  2. #include <avr/interrupt.h>
  3.  
  4. ISR (TIMER0_COMPA_vect)
  5. {
  6.     static uint8_t licznik = 0;
  7.     if (!licznik) { PORTB ^= _BV(5); }
  8.     if (++licznik > 8) { licznik = 0; }
  9. }
  10.  
  11. int main (void)
  12. {
  13.     DDRB |= _BV(5);
  14.    
  15.    
  16.     TCCR0B |= _BV(CS02) | _BV(CS00); // ustawiamy prescaler
  17.     TIMSK0 |= _BV(OCIE0A);
  18.    
  19.     sei();
  20.    
  21.     for (;;);
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement