Ticker Code

Dependencies:   mbed

Fork of Ticker_HelloWorld by mbed official

Files at this revision

API Documentation at this revision

Comitter:
bjs9
Date:
Wed Feb 28 09:56:15 2018 +0000
Parent:
0:5014bf742e9b
Commit message:
Ticker Code

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Feb 14 14:30:22 2013 +0000
+++ b/main.cpp	Wed Feb 28 09:56:15 2018 +0000
@@ -1,20 +1,37 @@
 #include "mbed.h"
  
 Ticker flipper;
+Ticker flipper2;
+Ticker flipper3;
+Ticker flipper4;
 DigitalOut led1(LED1);
 DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
  
 void flip() {
+    led1 = !led1;
+}
+void flip2() {
     led2 = !led2;
 }
+void flip3() {
+    led3 = !led3;
+}
+void flip4() {
+    led4 = !led4;
+}
  
 int main() {
+    led1 = 1;
     led2 = 1;
-    flipper.attach(&flip, 2.0); // the address of the function to be attached (flip) and the interval (2 seconds)
- 
+    led3 = 1;
+    led4 = 1;
+    flipper.attach(&flip, 1.0); // the address of the function to be attached (flip) and the interval (2 seconds)
+    flipper2.attach(&flip2, 2.0); // the address of the function to be attached (flip) and the interval (2 seconds)
+    flipper3.attach(&flip3, 4.0); // the address of the function to be attached (flip) and the interval (2 seconds)
+    flipper4.attach(&flip4, 8.0); // the address of the function to be attached (flip) and the interval (2 seconds)
     // spin in a main loop. flipper will interrupt it to call flip
     while(1) {
-        led1 = !led1;
-        wait(0.2);
     }
 }
\ No newline at end of file