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:
- 4:232f69c6c92c
- Parent:
- 3:a1263051d681
- Child:
- 5:0225e0fdab62
--- a/main.cpp Sun Nov 01 12:21:50 2020 +0000
+++ b/main.cpp Sun Nov 01 12:28:58 2020 +0000
@@ -1,22 +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
+DigitalOut trafficRedlight(p10); //Red light pin declaration
int main() {
- trafficYellowlight=1; //Initialize Yellow light to ON
+ trafficYellowlight=1; //Initialize Yellow light to ON
+ trafficRedlight=0; //Initialize Red light to OFF
while(1)
{
if(pedestrainButton & trafficYellowlight){
- int counter=0; // declaration and initialization of counter
+ 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=!trafficYellowlight; //Blinking Yellow light for 10 second
+ wait_ms(500); //delay of 5 second
}
- trafficYellowlight=0; //switch off yellow light
+ trafficYellowlight=0; //switch off yellow light
}
if(!trafficYellowlight){
- trafficYellowlight=!pedestrainButton; // Yellow light reamin switched OFF but once button is pressed to be OFF Yellow light will be ON
+ trafficYellowlight=!pedestrainButton; // Yellow light reamin switched OFF but once button is pressed to be OFF Yellow light will be ON
}
wait_ms(500);