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.
Dependencies: mbed
main.cpp
00001 /* Program Example 10: Event driven LED switching with switch debounce 00002 */ 00003 #include "mbed.h" 00004 InterruptIn button(PC_13); // Interrupt on digital pushbutton input p18 00005 DigitalOut led1(LED1); // digital out to LED1 00006 Timer debounce; // define debounce timer 00007 void toggle(void); // function prototype 00008 00009 int main() 00010 { 00011 debounce.start(); 00012 button.rise(&toggle); // attach the address of the toggle 00013 } 00014 00015 // function to the rising edge 00016 void toggle() 00017 { 00018 if (debounce.read_ms()>10) // only allow toggle if debounce timer 00019 led1=!led1; // has passed 10 ms 00020 debounce.reset(); // restart timer when the toggle is performed 00021 }
Generated on Fri Jul 15 2022 22:49:58 by
1.7.2