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.
main.cpp@2:a98660025857, 2020-11-01 (annotated)
- Committer:
- titig
- Date:
- Sun Nov 01 12:09:22 2020 +0000
- Revision:
- 2:a98660025857
- Parent:
- 1:aa3ea7b4673e
- Child:
- 3:a1263051d681
Once the Button is set to ON, make the YELLOW light blinks for 10 seconds, before switching it OFF
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
titig | 0:c7ce501d534b | 1 | #include "mbed.h" |
titig | 2:a98660025857 | 2 | DigitalOut trafficYellowlight(p5); //Yellow light pin declaration |
titig | 2:a98660025857 | 3 | DigitalIn pedestrainButton(p8); //Switch button pin declaration |
titig | 0:c7ce501d534b | 4 | int main() { |
titig | 2:a98660025857 | 5 | trafficYellowlight=1; //Initialize Yellow light to ON |
titig | 0:c7ce501d534b | 6 | while(1) |
titig | 0:c7ce501d534b | 7 | { |
titig | 0:c7ce501d534b | 8 | |
titig | 2:a98660025857 | 9 | if(pedestrainButton & trafficYellowlight){ |
titig | 2:a98660025857 | 10 | int counter=0; // declaration and initialization of counter |
titig | 2:a98660025857 | 11 | while(counter<10){ |
titig | 2:a98660025857 | 12 | counter+=1; |
titig | 2:a98660025857 | 13 | trafficYellowlight=!trafficYellowlight; //Blinking Yellow light for 10 second |
titig | 2:a98660025857 | 14 | wait_ms(500); //delay of 5 second |
titig | 2:a98660025857 | 15 | } |
titig | 2:a98660025857 | 16 | trafficYellowlight=0; //switch off yellow light |
titig | 2:a98660025857 | 17 | } |
titig | 2:a98660025857 | 18 | if(!trafficYellowlight){ |
titig | 2:a98660025857 | 19 | trafficYellowlight=!pedestrainButton; // Yellow light reamin switched OFF |
titig | 2:a98660025857 | 20 | } |
titig | 2:a98660025857 | 21 | |
titig | 2:a98660025857 | 22 | wait_ms(500); |
titig | 0:c7ce501d534b | 23 | } |
titig | 2:a98660025857 | 24 | } |