sfrgv

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
chifterben94
Date:
Wed Feb 01 09:23:49 2017 +0000
Commit message:
dd

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
--- /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();
+        }
+        
+    }
+}
+
+//---------------------------------------------
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Feb 01 09:23:49 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/ad3be0349dc5
\ No newline at end of file