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 #include "mbed.h" 00002 InterruptIn button(p30); // Interrupt on digital input p30 00003 DigitalOut led1(LED1); // digital out to onboard LED1 00004 Timer debounce; // define debounce timer 00005 LocalFileSystem local("local"); // define local file system 00006 void toggle(void); // function prototype 00007 00008 int main() 00009 { 00010 debounce.start(); // start debounce timer 00011 button.rise(&toggle); // attach the toggle function to the rising edge 00012 } 00013 void toggle() // perform toggle if debounce time has elapsed 00014 { 00015 if (debounce.read_ms()>200) { 00016 led1=!led1; // toggle LED 00017 FILE* Logfile = fopen ("/local/log.txt","a"); // open file for appending 00018 fprintf(Logfile,"time=%.3fs: setting led=%d\n\r",debounce.read(),led1.read()); 00019 fclose(Logfile); // close file 00020 debounce.reset(); // reset debounce timer 00021 } 00022 }
Generated on Sun Jul 24 2022 12:00:56 by
1.7.2