fgj

Dependencies:   mbed

Revision:
0:50094f63b4b9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Feb 06 13:19:02 2017 +0000
@@ -0,0 +1,61 @@
+#include "mbed.h"
+#include "C12832.h"
+
+DigitalOut LED(D13);
+DigitalIn BP(PC_13,PullNone);
+AnalogIn pot1(PA_0);
+Serial pc(SERIAL_TX, SERIAL_RX);
+Ticker t;
+Timer timer;
+
+int cpt=48, inactif;
+bool appui = false;
+
+void isr_LED(void)
+{
+        if(cpt>57)
+        {
+            cpt=48;
+            pc.putc(012);
+        }
+        if(appui)
+        {
+            pc.putc(cpt);
+            LED=!LED; 
+            cpt++;
+        }       
+}
+
+int main()
+{
+    pc.baud(38400);
+    t.attach(&isr_LED,0.25);   
+
+    while(1) 
+    {
+     if(BP==0 && !appui)
+     {
+        appui=true;
+        timer.reset();
+        while(BP==0);
+        timer.start();       
+     }
+      inactif = timer.read_ms();
+      
+        if(BP==0 && appui || inactif>10000)
+     {
+        appui=false;
+        if(inactif>10000)
+        {
+            Timeout timer;
+            t.attach(isr_LED,1);
+        }
+        timer.stop();
+        inactif=0;
+        cpt=48;
+        while(BP==0);       
+        pc.putc(012);
+        
+     }    
+    }
+}
\ No newline at end of file