FabLab Nîmes / Mbed 2 deprecated FabLab_TP_06

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Giamarchi
Date:
Sat Jan 12 00:43:50 2019 +0000
Child:
1:95172f59262a
Commit message:
Exo 2 : Chenillard

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	Sat Jan 12 00:43:50 2019 +0000
@@ -0,0 +1,60 @@
+/*************************************/
+//  YNCREA ISEN CSI3
+//  Electronique Numérique
+//
+//  Cours : Systèmes à microcontrôleur
+//  Prof : Frédéric Giamarchi
+//
+//  Exo 2.2 : Clignotemment de plusieurs Dels
+/*************************************/
+#include "mbed.h"
+
+DigitalOut L0(PB_1);
+DigitalOut L1(PB_2);
+DigitalOut L2(PB_10);
+DigitalOut L3(PB_11);
+DigitalOut L4(PB_12);
+DigitalOut L5(PB_13);
+DigitalOut L6(PB_14);
+DigitalOut L7(PB_15);
+
+uint8_t L[8] = {L0, L1, L2, L3, L4, L5, L6, L7};
+
+void set_8Dels(uint8_t position)
+{
+    L0 = position & 0x01;
+    L1 = position & 0x02;
+    L2 = position & 0x04;
+    L3 = position & 0x08;
+    L4 = position & 0x10;
+    L5 = position & 0x20;
+    L6 = position & 0x40;
+    L7 = position & 0x80;
+    
+//    L[!position] = 0;
+//    L[position] = 1; 
+}
+
+uint8_t compteur = 1;
+uint8_t sens = 0;
+
+int main()
+{
+    while(1)
+    {
+        wait(0.2);          // 200 ms
+        if(!sens)
+        {
+            compteur<<=1;         // décalage d'un bit vers la gauche
+            if(compteur == 0x80)
+                sens = 1;
+        }
+        else
+        {
+            compteur>>=1;         // décalage d'un bit vers la droite
+            if(compteur == 0x01)
+                sens = 0;
+        }
+        set_8Dels(compteur);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Jan 12 00:43:50 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file