Advertisement
uuu000

button on/off

Oct 7th, 2022
1,095
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #define F_CPU 8000000UL
  2. #include <avr/io.h>
  3. #include <avr/interrupt.h>
  4.  
  5. ISR(TIMER1_COMPA_vect)
  6. {
  7. if(PINB &(1 << PB1)) PORTB &= ~(1 << PB1);
  8. else PORTB |= (1<<PB1);
  9. }
  10.  
  11.  
  12. ISR(TIMER0_OVF_vect)
  13. {
  14. if(PINB &(1 << PB0)) PORTB&= ~(1 << PB0);
  15. else PORTB |= (1 << PB0);
  16. }
  17.  
  18. int main (void)
  19. {
  20.  
  21. DDRB = 0b11111111;
  22. PORTB = 0b0000000;
  23.  
  24. TCCR1A = 0b00000000;
  25. TCCR1B |= (1 << CS12)|(1 << WGM12);
  26. TCCR0 = 0b00000100;//делитель на 256
  27. OCR1AH = 0b00010101;
  28. OCR1AL = 0b00110000;
  29. TIMSK |=(1 << OCIE1A)|(1 << TOIE0);
  30. sei();
  31.  
  32. while (1)
  33. {}
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement