Charlie Saunders
/
32readingDigitalImputs
Switch and LED stuff
Revision 0:3f51bbc1f1a4, committed 2019-10-15
- Comitter:
- Thawedmind
- Date:
- Tue Oct 15 14:30:13 2019 +0000
- Commit message:
- Example code
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 Tue Oct 15 14:30:13 2019 +0000 @@ -0,0 +1,40 @@ + +#include "mbed.h" + +DigitalOut red_led(D7); +DigitalOut yellow_led(D6); +DigitalOut green_led(D5); +DigitalIn SW1(D4); + +int main() +{ + + //Switch on Yellow and Green to indicate + //that the code is running + yellow_led = 1; + green_led = 1; + red_led = 0; //Set RED LED to OFF + + while (1) { + + // Wait for SW1 to be pressed + while (SW1 == 0) { } + wait(0.2); + + red_led = 1; //Turn ON LED + + while (SW1 == 1) { } + wait(0.2); + + while (SW1 == 0) { } + wait(0.2); + + red_led = 0; //Turn ON LED + + while (SW1 == 1) { } + wait(0.2); + + } + + //Repeat forever +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Oct 15 14:30:13 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file