Dependencies:   mbed

Revision:
0:c2308f423597
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Sep 20 14:45:57 2018 +0000
@@ -0,0 +1,32 @@
+// Cecilia Schneider, OCE 360, September 20,2018
+// HW #1, exercise 5, Digital I/O
+// Lights up the blue and yellow LEDs after the switch has been changed 10 times 
+#include "mbed.h"
+Serial pc(USBTX, USBRX); //lets mbed communicate with pc via usb
+DigitalOut yled(p5);
+DigitalOut bled(p6);
+DigitalIn switch_input(p7);
+int main() {
+    
+    int count = 0;
+    yled = 0;
+    bled = 0;
+ 
+    while(count < 10) {
+        if(switch_input == 1){
+            int check_value = switch_input;
+            
+            wait(0.0025); //gets rid of the switch bounce
+ 
+            while(check_value){
+                if(check_value - switch_input == 1){
+                count++;
+                check_value = 0;
+pc.printf("DBG [%d] count: %d \r\n", __LINE__, count);
+                }
+            }
+        }
+    }
+    yled = 1;
+    bled = 1;
+}
\ No newline at end of file