VT4_Dean_Fraj

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
dfraj
Date:
Thu Nov 24 18:07:25 2016 +0000
Commit message:
VT_Dean_Fraj

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 5d08506cf3e3 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 24 18:07:25 2016 +0000
@@ -0,0 +1,22 @@
+#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 5d08506cf3e3 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 24 18:07:25 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/d75b3fe1f5cb
\ No newline at end of file