Luca Mottola
/
IOTAtelier1819-DISCO-ButtonInterrupt
Example using the user button on DISCO L475E IOT01, using interrupts
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 00003 InterruptIn button(USER_BUTTON); 00004 DigitalOut led(LED1); 00005 DigitalOut heartbeat(LED2); 00006 00007 void toggle() { 00008 led = !led; 00009 } 00010 00011 int main() { 00012 button.rise(&toggle); // Call toggle function on the rising edge 00013 while(1) { // Wait around, interrupts will interrupt this! 00014 heartbeat = !heartbeat; 00015 wait(0.25); 00016 } 00017 }
Generated on Wed Jul 20 2022 11:31:52 by 1.7.2