Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
TCNoodleshop
Date:
Mon Oct 07 02:38:49 2019 +0000
Parent:
0:5014bf742e9b
Commit message:
Lab 3 Part 3

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
diff -r 5014bf742e9b -r 46cfe79bd861 main.cpp
--- a/main.cpp	Thu Feb 14 14:30:22 2013 +0000
+++ b/main.cpp	Mon Oct 07 02:38:49 2019 +0000
@@ -3,18 +3,39 @@
 Ticker flipper;
 DigitalOut led1(LED1);
 DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
+int counter = 0;
+Serial pc(USBTX, USBRX);
  
 void flip() {
-    led2 = !led2;
+    led1 = !led1;
+    counter++;
+    pc.printf("%d\n\r", counter);
+    if(counter == 8)
+    {
+        led4 = !led4;
+        counter = 0;
+    }
+    if(counter % 4 == 0)
+    {
+        led3 = !led3;
+    }
+    if(counter % 2 == 0)
+    {
+        led2 = !led2;
+    }
 }
  
 int main() {
-    led2 = 1;
-    flipper.attach(&flip, 2.0); // the address of the function to be attached (flip) and the interval (2 seconds)
+    led1 = 0;
+    led2 = 0;
+    led3 = 0;
+    led4 = 0;
+    flipper.attach(&flip, 1.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
diff -r 5014bf742e9b -r 46cfe79bd861 mbed.bld
--- a/mbed.bld	Thu Feb 14 14:30:22 2013 +0000
+++ b/mbed.bld	Mon Oct 07 02:38:49 2019 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/0954ebd79f59
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file