Vjezba11_3
Dependencies: mbed
Revision 0:5117f0be3260, committed 2016-11-24
- Comitter:
- Goran002
- Date:
- Thu Nov 24 18:19:18 2016 +0000
- Commit message:
- VT4_Herek Goran
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 5117f0be3260 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Nov 24 18:19:18 2016 +0000 @@ -0,0 +1,21 @@ +#include "mbed.h" +InterruptIn button(p30); // Interrupt on digital input p30 +DigitalOut led1(LED1); // digital out to onboard LED1 +Timer debounce; // define debounce timer +LocalFileSystem local("local"); // define local file system +void toggle(void); // function prototype +int main() +{ + debounce.start(); // start debounce timer + button.rise(&toggle); // attach the toggle function to the rising edge +} +void toggle() // perform toggle if debounce time has elapsed +{ + if (debounce.read_ms()>200) { + led1=!led1; // toggle LED + FILE* Logfile = fopen ("/local/log.txt","a"); // open file for appending + fprintf(Logfile,"time=%.3fs: setting led=%d\n\r",debounce.read(),led1.read()); + fclose(Logfile); // close file + debounce.reset(); // reset debounce timer + } +} \ No newline at end of file
diff -r 000000000000 -r 5117f0be3260 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Nov 24 18:19:18 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/d75b3fe1f5cb \ No newline at end of file