Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 1:5ceb4255be68
- Parent:
- 0:dd0d7dbadcbd
- Child:
- 2:4eff114c7219
--- a/main.cpp Thu May 27 13:58:36 2021 +0000 +++ b/main.cpp Thu May 27 15:20:42 2021 +0000 @@ -2,11 +2,74 @@ DigitalOut myled(LED1); +DigitalIn mySwitch(p7); + +DigitalOut yellowLed(p5); + +DigitalOut redLed(p6); + +int switchState = 0; + +void BlinkYellowLed() +{ + yellowLed =1; + wait(0.5); + yellowLed = 0; + wait(0.5); + + } + + int main() { - while(1) { - myled = 1; - wait(0.2); - myled = 0; - wait(0.2); + printf("Start program \n"); + printf("Initialize yellow Led to on \n") + yellowLed = 1; + redLed= 0; + switchState = 0; + + while(1) { + printf("Entered Loop \n"); + + + printf("Value of my switch %d\n", mySwitch.read()); + printf("Switch state %d\n", switchState); + + if(mySwitch == 1) + { + printf("Value of my switch %d\n", mySwitch.read()); + + yellowLed = 0; + wait(0.5); + + if(switchState == 0) + { + + for(int i =0; i<5; i++) + { + BlinkYellowLed(); + + } + + yellowLed = 0; + switchState = 1; + + + } + + else + { + yellowLed = 0; + switchState = 1; + } + + + } + else + { + yellowLed = 1; + switchState = 1; + } + + wait_ms(500); } }