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:602c96685466, 2020-11-01 (annotated)
- Committer:
- harerimana
- Date:
- Sun Nov 01 13:11:26 2020 +0000
- Revision:
- 2:602c96685466
- Parent:
- 1:18bf4c2c22ec
- Child:
- 3:b1c994da96f5
Once the Button is set to ON, make the YELLOW light blinks for 5 seconds, before switching it OFF
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
harerimana | 1:18bf4c2c22ec | 1 | #include "mbed.h" |
harerimana | 1:18bf4c2c22ec | 2 | DigitalOut trafficYellowlight(p7); |
harerimana | 1:18bf4c2c22ec | 3 | DigitalIn pedestrainButton(p8); |
harerimana | 0:392dea3408f2 | 4 | int main() { |
harerimana | 2:602c96685466 | 5 | trafficYellowlight=1; |
harerimana | 0:392dea3408f2 | 6 | while(1) |
harerimana | 0:392dea3408f2 | 7 | { |
harerimana | 2:602c96685466 | 8 | if(pedestrainButton&trafficYellowlight){ |
harerimana | 2:602c96685466 | 9 | int counter=0; |
harerimana | 2:602c96685466 | 10 | printf("counter is now%d\n",counter); |
harerimana | 2:602c96685466 | 11 | // blink for 5 seconds |
harerimana | 2:602c96685466 | 12 | while(counter<10){ |
harerimana | 2:602c96685466 | 13 | counter+=1; |
harerimana | 2:602c96685466 | 14 | trafficYellowlight=!trafficYellowlight; |
harerimana | 2:602c96685466 | 15 | wait_ms(5000);//delay of 5 seconds |
harerimana | 2:602c96685466 | 16 | } |
harerimana | 2:602c96685466 | 17 | trafficYellowlight=0;//switch off |
harerimana | 2:602c96685466 | 18 | } |
harerimana | 2:602c96685466 | 19 | if(!trafficYellowlight){ |
harerimana | 2:602c96685466 | 20 | trafficYellowlight=!pedestrainButton; |
harerimana | 2:602c96685466 | 21 | } |
harerimana | 0:392dea3408f2 | 22 | |
harerimana | 0:392dea3408f2 | 23 | wait_ms(5000); |
harerimana | 0:392dea3408f2 | 24 | } |
harerimana | 2:602c96685466 | 25 | } |
harerimana | 1:18bf4c2c22ec | 26 |