Dependencies: mbed
Revision 0:ae568851512d, committed 2014-10-20
- Comitter:
- cstab94
- Date:
- Mon Oct 20 00:13:18 2014 +0000
- Commit message:
- LED code for copying/editing
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 000000000000 -r ae568851512d main.cpp --- /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 + } + } +}
diff -r 000000000000 -r ae568851512d mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Oct 20 00:13:18 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1 \ No newline at end of file