BlinkTicker123

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
redona
Date:
Thu Nov 15 17:00:05 2018 +0000
Parent:
0:d9ec23dd131e
Commit message:
BlinkTicker123

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r d9ec23dd131e -r 253ac8e04eba main.cpp
--- a/main.cpp	Thu Nov 08 12:18:12 2018 +0000
+++ b/main.cpp	Thu Nov 15 17:00:05 2018 +0000
@@ -3,15 +3,27 @@
 Ticker toggle_led_ticker;
 
 DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+
+int counter = 0; 
 
 void toggle_led() {
-    led1 = !led1;
+    // We give the bits value of 1 and shifting the bits to the left based on the right number.
+     (counter & (1 << (0))) ? led1 =1 : led1 = 0;
+     
+     (counter & (1 << (1))) ?  led2 = 1 : led2 = 0;
+   
+     counter & (1 << (2)) ? led3 = 1 : led3 = 0;
+
 }
 
 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);
+    // Init the ticker with the address of the function (toggle_led) to be attached and the interval (2000 ms)
+    toggle_led_ticker.attach(&toggle_led, 2);
     while (true) {
-        // Do other things...
+    // increment the counter
+        wait(2);
+        counter ++;
     }
 }
\ No newline at end of file