BlinkTicker123

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
alessioburatti
Date:
Fri Nov 16 11:57:39 2018 +0000
Parent:
0:d9ec23dd131e
Commit message:
Done

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Nov 08 12:18:12 2018 +0000
+++ b/main.cpp	Fri Nov 16 11:57:39 2018 +0000
@@ -3,15 +3,30 @@
 Ticker toggle_led_ticker;
 
 DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
 
-void toggle_led() {
-    led1 = !led1;
+static int value = 0;
+
+#define LEAST_1 1
+#define LEAST_2 1 << 1
+#define LEAST_3 1 << 2
+
+void toggle_leds() {
+    led1 = value & LEAST_1;
+    led2 = value & LEAST_2;
+    led3 = value & LEAST_3;
 }
 
 int main() {
     // Init the ticker with the address of the function (toggle_led) to be attached and the interval (100 ms)
-    toggle_led_ticker.attach(&toggle_led, 0.1);
+    
+    toggle_led_ticker.attach(&toggle_leds, 0.1);
     while (true) {
-        // Do other things...
+        value++;
+        if (value == 256) {
+            value = 0;
+        }
+        wait(1);
     }
 }
\ No newline at end of file