Setting a certain time / counter D0 as a count button interrupt --- "Judgment timer D0 is open or close? 1. When it is a relationship - "Read key value ---" check the key (level signal) is low, then D0.2. When it is open (explained that it is another button, that is, triggered again Press button interrupt) --- "Guan D0 ---" Read key value D0 interrupt, check Key is low --- "The same key value (equal to reading a key value) Check KEY is high -" Off D0 below Press the code outside the interrupt: #pragma interrupt_handler INT1_ISR: 3VOID INT1_ISR (void) {// unsigned char Temp; // cli (); EICRA = 0x00; EIMSK = 0x00; // delay_1ms (); // Power-on Reset Timer0_counter = 0; time0_times = 0; if (TIMSK & 0x01 == 1) // Timer counter open {TIMSK & = ~ (1 << TOIE0); // Off counter 0 overflow interrupt} ELSE / / Timer counter {IF ((Pind & 0x02) = = 0) // and PD1 is low {TIMSK | = (1 << toie0); // Open counter 0 overflow interrupt}} key_number [key_counter] = read7279 (cmd_read); key_counter ; if (key_counter == 9) Key_counter = 0; eicra = 0x08; SEI (); EIMSK = 0x02; Timer0_counter = 0;} The following is the code below D0 interrupt: #pragma interrupt_handler Timer0_isr: 17 // Timer 0 overflow interrupt Void Timer0_ism (void) {ix ( PIND & 0x02)! = 0) // PD1 = 1, Key is high {TIMSK & = ~ (1 << TOIE0); // Off counter 0 overflow interrupt} else {if (Timer0_times == 200) Timer0_times = 2; Timer0_counter ; IF (Timer0_counter == 20) {TIMER0_TIMES ; IF (Timer0_times> 1) {TIMER0_COUNTER = 0; key_number [key_counter] = front_num; key_counter ; if (key_counter == 9) Key_Counter = 0;}}}
// TIMSK = 0; // Off counter 0 overflow interrupt // wink_move ();}