Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/io.h>
- #include <avr/interrupt.h>
- #include <avr/sleep.h>
- ISR(INT0_vect){
- TCCR0B|=(1<<CS00)|(1<<CS02);
- PORTB &=(~(1<<PB3));
- PORTB|=(1<<PB2);
- }
- ISR(PCINT0_vect){
- TCCR0B|=(1<<CS00)|(1<<CS02);
- PORTB &=(~(1<<PB2));
- PORTB|=(1<<PB3);
- }
- ISR(TIM0_OVF_vect){
- TCCR0B&=(~((1<<CS00)|(1<<CS02)));
- PORTB &=(~(1<<PB2));
- PORTB &=(~(1<<PB3));
- }
- int main(void)
- {
- DDRB|=(1<<PB2)|(1<<PB3);
- TIMSK0|=(1<<TOIE0);
- PCMSK|=(1<<PCINT0);
- MCUCR=0b00110011;
- GIMSK=0b01100000;
- set_sleep_mode(SLEEP_MODE_IDLE);
- sei();
- while(1)
- {
- sleep_enable(); // разрешаем сон
- sleep_cpu(); // спать!
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment