Program for Interrupt button
Dependencies: mbed
Fork of Board1Prg2 by
main.cpp
00001 #include "mbed.h" 00002 00003 DigitalOut myled(LED1); 00004 //DigitalIn button1(USER_BUTTON); 00005 InterruptIn button1(USER_BUTTON); 00006 00007 bool active = false; 00008 00009 void BUTTON_ISR(){ 00010 active = !active; 00011 } 00012 00013 int main() { 00014 // Set up 00015 button1.mode(PullUp); 00016 button1.fall(&BUTTON_ISR); 00017 00018 while(1) { 00019 if(active == true){ 00020 myled = 1; // LED is ON 00021 wait(0.2); // 200 ms 00022 myled = 0; // LED is OFF 00023 wait(0.2); 00024 myled = 1; // LED is ON 00025 wait(0.2); // 200 ms 00026 myled = 0; // LED is OFF 00027 wait(1.0); // 1 sec 00028 } 00029 else{ 00030 myled = 0; 00031 } 00032 __wfi(); //Wait for interruptions 00033 } 00034 } 00035 00036
Generated on Fri Jul 15 2022 02:12:54 by
1.7.2
