![]() ![]() Internal names (which you can use to set up ISR callbacks) are in brackets. In a more complicated example, the main loop might be doing something useful, like taking temperature readings, and allow the interrupt handler to detect a button being pushed.Ģ External Interrupt Request 0 (pin D2) (INT0_vect)ģ External Interrupt Request 1 (pin D3) (INT1_vect)Ĥ Pin Change Interrupt Request 0 (pins D8 to D13) (PCINT0_vect)ĥ Pin Change Interrupt Request 1 (pins A0 to A5) (PCINT1_vect)Ħ Pin Change Interrupt Request 2 (pins D0 to D7) (PCINT2_vect)Ĩ Timer/Counter2 Compare Match A (TIMER2_COMPA_vect)ĩ Timer/Counter2 Compare Match B (TIMER2_COMPB_vect)ġ0 Timer/Counter2 Overflow (TIMER2_OVF_vect)ġ1 Timer/Counter1 Capture Event (TIMER1_CAPT_vect)ġ2 Timer/Counter1 Compare Match A (TIMER1_COMPA_vect)ġ3 Timer/Counter1 Compare Match B (TIMER1_COMPB_vect)ġ4 Timer/Counter1 Overflow (TIMER1_OVF_vect)ġ5 Timer/Counter0 Compare Match A (TIMER0_COMPA_vect)ġ6 Timer/Counter0 Compare Match B (TIMER0_COMPB_vect)ġ7 Timer/Counter0 Overflow (TIMER0_OVF_vect)ġ8 SPI Serial Transfer Complete (SPI_STC_vect)Ģ0 USART, Data Register Empty (USART_UDRE_vect)Ģ5 2-wire Serial Interface (I2C) (TWI_vect)Ģ6 Store Program Memory Ready (SPM_READY_vect) The change in the pin is detected by a CHANGE interrupt, which causes the Interrupt Service Routine (ISR) to be called. ![]() The internal pullup (enabled in setup) forces the pin HIGH normally. To test this, just connect a wire (or switch) between D2 and Ground. This example shows how, even though the main loop is doing nothing, you can turn the LED on pin 13 on or off, if the switch on pin D2 is pressed. PinMode (LED, OUTPUT) // so we can update the LEDĭigitalWrite (BUTTON, HIGH) // internal pull-up resistorĪttachInterrupt (digitalPinToInterrupt (BUTTON), switchPressed, CHANGE) // attach interrupt handler ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |