Blinky LED test for ST Nucleo boards

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Wiegerinck
Date:
Wed Mar 28 11:32:58 2018 +0000
Parent:
6:4e6ec83d3c83
Commit message:
Teste_1

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Sep 13 11:30:50 2017 +0000
+++ b/main.cpp	Wed Mar 28 11:32:58 2018 +0000
@@ -1,12 +1,64 @@
 #include "mbed.h"
 
 DigitalOut myled(LED1);
+DigitalOut T1(PB_3);
+DigitalOut T2(PB_4);
+DigitalOut T3(PB_5);
+DigitalOut T4(PB_10);
+
+int val = 0;
 
 int main() {
     while(1) {
-        myled = 1; // LED is ON
-        wait(0.2); // 200 ms
-        myled = 0; // LED is OFF
-        wait(1.0); // 1 sec
+        while(val <= 50) {
+            myled = 1; // LED is ON
+            T1 = 1;
+            T2 = 0;
+            T3 = 0;
+            T4 = 0;
+            wait(0.01); // 200 ms
+            myled = 0; // LED is OFF
+            T1 = 0;
+            T2 = 1;
+            T3 = 0;
+            T4 = 0;
+            wait(0.01); // 1 sec
+            T1 = 0;
+            T2 = 0;
+            T3 = 1;
+            T4 = 0;
+            wait(0.01);
+            T1 = 0;
+            T2 = 0;
+            T3 = 0;
+            T4 = 1;
+            wait(0.01);
+            val = val + 1;
+        }
+        while(val >= 0) {
+            myled = 1; // LED is ON
+            T1 = 0;
+            T2 = 0;
+            T3 = 1;
+            T4 = 0;
+            wait(0.01); // 200 ms
+            myled = 0; // LED is OFF
+            T1 = 0;
+            T2 = 1;
+            T3 = 0;
+            T4 = 0;
+            wait(0.01); // 1 sec
+            T1 = 1;
+            T2 = 0;
+            T3 = 0;
+            T4 = 0;
+            wait(0.01);
+            T1 = 0;
+            T2 = 0;
+            T3 = 0;
+            T4 = 1;
+            wait(0.01);
+            val = val - 1;
+        }
     }
 }