sfrgv

Dependencies:   mbed

Revision:
0:5f492aa92a41
diff -r 000000000000 -r 5f492aa92a41 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Feb 01 09:23:49 2017 +0000
@@ -0,0 +1,64 @@
+#include "mbed.h"
+
+//--------------------------------------------- VARIABLES ET CLASSES
+
+Ticker ticker;
+Timer timer;
+Serial pc(USBTX,USBRX);
+InterruptIn bouton(USER_BUTTON);
+
+int transmissionActive = 0;
+static char nombreAEnvoyer = '0';
+
+//--------------------------------------------- ENVOYER
+
+void envoyerNombre(){
+    
+    if(transmissionActive == 1)
+    {
+        pc.putc(nombreAEnvoyer);
+        
+        nombreAEnvoyer ++;
+        if (nombreAEnvoyer > '9')
+        {
+            nombreAEnvoyer = '0';
+        } 
+    }
+ 
+}
+
+//--------------------------------------------- ARRETER L'ENVOI
+
+void stopEnvoie(){
+
+    transmissionActive = 0;    
+}
+
+//--------------------------------------------- MAIN
+
+int main() {
+    
+    ticker.attach(&envoyerNombre,1);
+    
+    
+    while(1) {
+        
+        if(bouton == 0)
+        {
+          timer.reset();
+          nombreAEnvoyer = '0';
+          transmissionActive = !transmissionActive;
+          while (bouton == 0){} 
+          timer.start();
+          
+        }
+        
+        if (timer.read() == 10)
+        {
+            stopEnvoie();
+        }
+        
+    }
+}
+
+//---------------------------------------------