
Lights the LEDs after the switch has been changed 10 times
Revision 0:c2308f423597, committed 2018-09-20
- Comitter:
- ccschneider
- Date:
- Thu Sep 20 14:45:57 2018 +0000
- Commit message:
- Lights the LEDs after the switch has been changed 10 times
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 |
--- /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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Sep 20 14:45:57 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187 \ No newline at end of file