switches and lights
Dependencies: mbed
Revision 0:a6003d0979bf, committed 2014-10-15
- Comitter:
- jkangwi
- Date:
- Wed Oct 15 19:13:59 2014 +0000
- Commit message:
- lab 3, switches and lights
;
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 a6003d0979bf main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Oct 15 19:13:59 2014 +0000 @@ -0,0 +1,36 @@ +#include "mbed.h" +// Lab 3 +// This program explores the basic capabilites of the digital I/O on the processor +// Written by: MIDN 3/C N. Weinhardt, MIDN 3/C J. Kangwijaya, 09/22/14 +//Modified: +// 9/23/14 MIDN 3/C. Weinhardt. Corrected last if else statement. +BusOut zed(p5, p6, p7, p8, p11); //data bus for LEDs +DigitalIn sw4(p16); // switch for control of LEDs +DigitalIn sw5 (p17); // switch for control of LEDs +int w1; // variable to store switch 4 +int w2; // variable to store switch 5 +main() +{ + int x; // variable to store binary input + w1=sw5; // variable to store switch 5 + w2=sw4; // variable to store switch 4 + x=4; // displays 0b0100 on LEDs + zed=x; // read switch into variable + while(1) { // infinite while loop + + if(w1==1 && w2==1) { // if sw5 and sw4 are on + x=4; // displays 0b0100 on LEDs + zed=x; // read switch into variable + + } else if (w1==1 &&w2==0) { // if sw5 is on and sw4 is off + x=x/2; // x equals the variable divided by 2 to be displayed on the LEDs + zed=x; // read switch into variable + wait(0.5); // change the value every 0.5 seconds + } else if (w1==0 && w2==1) { // if sw5 is off and sw4 is on + x=x*2; // x equals the variable multiplied by 2 to be displayed on the LEDs + zed=x; // read switch into variable + wait(0.5); // change the value every 0.5 seconds + } + } + +} \ No newline at end of file
diff -r 000000000000 -r a6003d0979bf mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Oct 15 19:13:59 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1 \ No newline at end of file