c

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Saide
Date:
Sun Apr 26 08:12:26 2020 +0000
Parent:
0:bdb6d686a9cf
Commit message:
j

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r bdb6d686a9cf -r 0b65d1f1d8f7 main.cpp
--- a/main.cpp	Wed Feb 12 08:49:58 2020 +0000
+++ b/main.cpp	Sun Apr 26 08:12:26 2020 +0000
@@ -1,36 +1,85 @@
 #include "mbed.h"
 
 
+void allumerLed(int);
+
+void eteindreLed(int);
+
+char valeurLed[1]; 
+
+
+
 I2C LED (p9,p10);
 const int addr = 0x7e;
-int main() {
+
+
+int main()
+{
+    valeurLed[0]= 0xff;
+    int i=1;
     char cmd[2];
-   // LED.write(0x7e);
-        
+    cmd[0]=0x00;
+    LED.write(addr,cmd,1);
     while(1) {
-     /*cmd[0] = 0x4;            // pointer to command register
-     cmd[1] = 0x0;           // Start ranging, results in cm
-     LED.write(addr, cmd, 2); // Send command string
-     wait(0.07); */ 
-     
-     cmd[0] = 0xAA;
-     LED.write(addr, cmd, 1);
-     LED.read(addr, cmd, 2); // read the two-byte echo result
-     //LED.write(0x7e, &A,1);
-     
-     /*wait(0.5);
-     
-     cmd[0] = 0xff;
-     LED.write(addr, cmd, 1);
-     LED.read(addr, cmd, 2); // read the two-byte echo result*/
-     
-     wait(0.5) ; 
-     
-     cmd[0] = 0x55;
-     LED.write(addr, cmd, 1);
-     LED.read(addr, cmd, 2); // read the two-byte echo result
-     
-     wait(0.5) ;
-     
+        allumerLed((i%8)+1);
+        i++;
+        wait(1);
+
     }
+
+
 }
+
+
+void allumerLed(int numLed)
+{
+    switch(numLed) 
+    {
+        case 1 :
+            valeurLed[0]=0x01;
+            
+            break;
+
+
+        case 2 :
+            valeurLed[0]=0x02;
+            break;
+
+
+        case 3 :
+            valeurLed[0]=0x04;
+            break;
+
+        case 4 :
+            valeurLed[0]=0x08;
+            break;
+
+        case 5 :
+            valeurLed[0]=0x10;
+            break;
+
+        case 6 :
+            valeurLed[0]=0x20;
+            break;
+
+        case 7 :
+            valeurLed[0]=0x40;
+            break;
+
+        case 8 :
+            valeurLed[0]=0x80;
+            break;
+
+       default :
+            valeurLed[0]=0x00;
+            break;
+    }
+   valeurLed[0]=valeurLed[0]&0xff;
+    LED.write(addr,valeurLed,1);
+}
+
+
+void eteindreLed(int numLed)
+{
+
+}
\ No newline at end of file