TD

Dependencies:   mbed

Committer:
jomfec
Date:
Mon May 02 09:06:17 2016 +0000
Revision:
0:85af55b43299
INFO2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jomfec 0:85af55b43299 1 #include "mbed.h"
jomfec 0:85af55b43299 2 InterruptIn button(p30);
jomfec 0:85af55b43299 3 Timer debounce;
jomfec 0:85af55b43299 4 LocalFileSystem local("local");
jomfec 0:85af55b43299 5 char read_string[64];
jomfec 0:85af55b43299 6 void toggle(void);
jomfec 0:85af55b43299 7 int main() {
jomfec 0:85af55b43299 8 debounce.start();
jomfec 0:85af55b43299 9 printf("Saisir le texte: ");
jomfec 0:85af55b43299 10 scanf( "%s",read_string);
jomfec 0:85af55b43299 11 button.rise(&toggle);
jomfec 0:85af55b43299 12 while(1);
jomfec 0:85af55b43299 13 }
jomfec 0:85af55b43299 14 void toggle() {
jomfec 0:85af55b43299 15 if (debounce.read_ms()>200) {
jomfec 0:85af55b43299 16 FILE* pfile = fopen ("/local/log.txt","a");
jomfec 0:85af55b43299 17 fprintf(pfile,"%s",read_string);
jomfec 0:85af55b43299 18 fclose(pfile); // close file
jomfec 0:85af55b43299 19 debounce.reset(); // reset debounce timer
jomfec 0:85af55b43299 20 }
jomfec 0:85af55b43299 21 }