Matthew Sims
/
Lab1A
Lab 1 Program A
Revision 0:0db95f8cd85f, committed 2015-09-29
- Comitter:
- mattsims12
- Date:
- Tue Sep 29 00:52:41 2015 +0000
- Commit message:
- Version 1
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 0db95f8cd85f main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Sep 29 00:52:41 2015 +0000 @@ -0,0 +1,41 @@ +/*Lab 1 Program A + Makes led's shift based on which input switches are on. + Matthew Sims + Section 1001 +*/ + +#include "mbed.h" + +DigitalOut out[]= {p30,p29,p28,p27,p26}; //sets 5 output pins connected to circut board led's +DigitalIn in[]={p16,p17}; //sets 2 inputs to the pins the switches are connected to + +int main() +{ + out[2]=1; //Initial postion led 2 lit + int lit=2; //Records which led is lit + + /*Infinite loop that checks which inputts are on every cycle and changes led's bassed on inputs*/ + + while(1) { + if(in[0]==1 && in[1]==1) { //Checks first instance + out[lit]=0; //Turns off currently on led + lit=2; //Picks middle led to be lit + out[lit]=1; //Turns on the selected led + wait(.5); //Turns on the selected led + } else if(in[0]==1 && in[1]==0) { //Checks second instance + if(lit<4) { //Makes sure it stops at end of array + out[lit]=0; //Turns previously on led off + lit++; //Picks led to right + out[lit]=1; //Turns on led + wait(.5); //Waits to start loop again + } + } else if(in[1]==1 && in[0]==0) { //Same as last loop, but moves led's to left instead of right. + if(lit>0) { + out[lit]=0; + lit--; + out[lit]=1; + wait(.5); + } + } + } +} \ No newline at end of file
diff -r 000000000000 -r 0db95f8cd85f mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Sep 29 00:52:41 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4f6c30876dfa \ No newline at end of file