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:
- 2:a98660025857
- Parent:
- 1:aa3ea7b4673e
- Child:
- 3:a1263051d681
--- a/main.cpp Sun Nov 01 12:06:47 2020 +0000 +++ b/main.cpp Sun Nov 01 12:09:22 2020 +0000 @@ -1,11 +1,24 @@ #include "mbed.h" -DigitalOut trafficYellowlight(p5); //Yellow light pin declaration -DigitalIn pedestrainButton(p8); //Switch button pin declaration +DigitalOut trafficYellowlight(p5); //Yellow light pin declaration +DigitalIn pedestrainButton(p8); //Switch button pin declaration int main() { + trafficYellowlight=1; //Initialize Yellow light to ON while(1) { - trafficYellowlight=1; //Initialize Yellow light to ON - wait_ms(500); + if(pedestrainButton & trafficYellowlight){ + int counter=0; // declaration and initialization of counter + while(counter<10){ + counter+=1; + trafficYellowlight=!trafficYellowlight; //Blinking Yellow light for 10 second + wait_ms(500); //delay of 5 second + } + trafficYellowlight=0; //switch off yellow light + } + if(!trafficYellowlight){ + trafficYellowlight=!pedestrainButton; // Yellow light reamin switched OFF + } + + wait_ms(500); } - } +} \ No newline at end of file