Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 00003 InterruptIn mybutton(USER_BUTTON);//generates an object named mybutton out of the class InterruptIn 00004 DigitalOut myled(LED1); // 00005 00006 volatile float delay = 4.0; // 1 sec of delay in the delay 00007 volatile bool Pressedornot=false; // global variable with is updated by the interrupt function 00008 00009 /*function pressed() is called than a interrupt is generated by the external interrupt when the userbutton is pressed 00010 it alters the Pressedornot variable from true to false 00011 */ 00012 void pressed() 00013 { 00014 if (Pressedornot==false) 00015 Pressedornot=true; 00016 else 00017 Pressedornot=false; 00018 } 00019 00020 int main() 00021 { 00022 mybutton.fall(&pressed);//activates the interrupt then a falling edge is detected on the pin 00023 while (1) { 00024 while(Pressedornot==false) { 00025 myled = !myled; 00026 for(int i=0;i<1000000;i++)// 00027 {wait_us(1); 00028 if(Pressedornot==true) 00029 {break;} 00030 } 00031 } while( Pressedornot==true ) 00032 { 00033 myled=true; 00034 } 00035 00036 } 00037 }
Generated on Mon Aug 1 2022 01:25:32 by
1.7.2