External Interrupt
The onboard USR button connects to P6 (GPIO37/EINT20). To use this button as an input, you can either poll the pin state with digitalRead,
or use the EINT APIs in Arduino.
With Digital Read
Change the LED pin from 13 to 7, for example:
Change the button pin from 2 to 6, for example:
Now upload the sketch to the board. The onboard USR LED should light up when the USR button is pressed.
With EINT API
Arduino provides APIs to handle EINT(external interrupts), and only 4 pins on LinkIt 7697 support EINT function. As an example, you'll learn how to use USR button (P6/GPIO37/EINT20) with the EINT API.
Open Arduino IDE and copy the following code to the editor:
In the example code above, when the button is pressed (RISING edge), the pin_change
callback will be invoked. In the function, you change the state of the LED. After uploading this sketch to the board, press the USR button to turn on the USR LED, and press again to turn it off.
Note that only P1, P2, P3 and P6 support the attachInterrupt
API.
Last updated