Dependencies:   mbed

Revision:
0:ae568851512d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Oct 20 00:13:18 2014 +0000
@@ -0,0 +1,41 @@
+//mbed_digital I/O lab
+//This program changes LEDs on a control board to demonstrate BusOut and DigitalIn functions
+//Written by: MIDN 3/C K. Schaff, MIDN 3/C C. Stabler, 9/22/14
+
+#include "mbed.h"
+
+
+int main() {
+    BusOut w(p5, p6, p7, p8, p11);  //data bus for LEDs
+    
+
+    int switch1; //values for storing switch positions
+    int switch2;
+    
+    DigitalIn sw1(p16); //inputs for switches 1 and 2
+    DigitalIn sw2(p17);
+    
+
+    w = 4;  //initial value for p7 LED to be on
+    while(1)    //runs loop infinitely
+    {
+        switch1 = sw1.read(); //stores input from sw1 and sw2, constantly updating inside the loop
+        switch2 = sw2.read();
+        
+        if(sw1==1 && sw2==1)    //condition of switches to control LEDs
+        {
+            w = 4;  //binary number for setting third LED on
+            wait(.5); //changes value every half-second
+        }
+        else if(sw1==1) //condition of switches to control LEDs
+        {
+            w = w/2;    //moves LED to the right by changing binary value
+            wait(.5);   //changes value every half-second
+        }
+        else if(sw2==1) //condition of switches to control LEDs
+        {
+            w = w*2;    //moves LED to the left by changing binary value
+            wait(.5);   //changes value every half-second
+        }
+    }
+}