TD

Dependencies:   mbed

exercice4.cpp

Committer:
jomfec
Date:
2016-05-02
Revision:
0:85af55b43299

File content as of revision 0:85af55b43299:

#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  
  }  
}