Diff: exercice4.cpp
- Revision:
- 0:85af55b43299
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exercice4.cpp Mon May 02 09:06:17 2016 +0000
@@ -0,0 +1,21 @@
+#include "mbed.h"
+InterruptIn button(p30);
+Timer debounce;
+LocalFileSystem local("local");
+char read_string[64];
+void toggle(void);
+int main() {
+debounce.start();
+printf("Saisir le texte: ");
+scanf( "%s",read_string);
+button.rise(&toggle);
+while(1);
+}
+void toggle() {
+ if (debounce.read_ms()>200) {
+ FILE* pfile = fopen ("/local/log.txt","a");
+ fprintf(pfile,"%s",read_string);
+ fclose(pfile); // close file
+ debounce.reset(); // reset debounce timer
+ }
+}
\ No newline at end of file