Guest User

Untitled

a guest
Sep 22nd, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <avr/io.h>
  2. #include <avr/interrupt.h>
  3. #include <avr/sleep.h>
  4. ISR(INT0_vect){
  5. TCCR0B|=(1<<CS00)|(1<<CS02);
  6. PORTB &=(~(1<<PB3));
  7. PORTB|=(1<<PB2);
  8. }
  9. ISR(PCINT0_vect){
  10. TCCR0B|=(1<<CS00)|(1<<CS02);
  11. PORTB &=(~(1<<PB2));
  12. PORTB|=(1<<PB3);
  13. }
  14. ISR(TIM0_OVF_vect){
  15. TCCR0B&=(~((1<<CS00)|(1<<CS02)));
  16. PORTB &=(~(1<<PB2));
  17. PORTB &=(~(1<<PB3));
  18.  
  19. }
  20. int main(void)
  21. {
  22. DDRB|=(1<<PB2)|(1<<PB3);
  23. TIMSK0|=(1<<TOIE0);
  24. PCMSK|=(1<<PCINT0);
  25. MCUCR=0b00110011;
  26. GIMSK=0b01100000;
  27. set_sleep_mode(SLEEP_MODE_IDLE);
  28. sei();
  29.  
  30. while(1)
  31. {
  32. sleep_enable(); // разрешаем сон
  33. sleep_cpu(); // спать!
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment