Mirembe Jean d'Amour / Mbed 2 deprecated ASSIGNMENT_CODES

Dependencies:   mbed

Committer:
titig
Date:
Sun Nov 01 12:35:03 2020 +0000
Revision:
5:0225e0fdab62
Parent:
4:232f69c6c92c
Child:
6:2aa20d4e28e4
When the YELLOW light is completely OFF then switch ON the RED light;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
titig 5:0225e0fdab62 1 #include "mbed.h" // Including Mbed Libraries
titig 4:232f69c6c92c 2 DigitalOut trafficYellowlight(p5); //Yellow light pin declaration
titig 4:232f69c6c92c 3 DigitalIn pedestrainButton(p8); //Switch button pin declaration
titig 4:232f69c6c92c 4 DigitalOut trafficRedlight(p10); //Red light pin declaration
titig 0:c7ce501d534b 5 int main() {
titig 4:232f69c6c92c 6 trafficYellowlight=1; //Initialize Yellow light to ON
titig 4:232f69c6c92c 7 trafficRedlight=0; //Initialize Red light to OFF
titig 0:c7ce501d534b 8 while(1)
titig 0:c7ce501d534b 9 {
titig 0:c7ce501d534b 10
titig 2:a98660025857 11 if(pedestrainButton & trafficYellowlight){
titig 4:232f69c6c92c 12 int counter=0; // declaration and initialization of counter
titig 2:a98660025857 13 while(counter<10){
titig 2:a98660025857 14 counter+=1;
titig 4:232f69c6c92c 15 trafficYellowlight=!trafficYellowlight; //Blinking Yellow light for 10 second
titig 4:232f69c6c92c 16 wait_ms(500); //delay of 5 second
titig 2:a98660025857 17 }
titig 5:0225e0fdab62 18 trafficYellowlight=0; //switch OFF yellow light
titig 5:0225e0fdab62 19 trafficRedlight=1; //switch ON Red light
titig 2:a98660025857 20 }
titig 2:a98660025857 21 if(!trafficYellowlight){
titig 4:232f69c6c92c 22 trafficYellowlight=!pedestrainButton; // Yellow light reamin switched OFF but once button is pressed to be OFF Yellow light will be ON
titig 2:a98660025857 23 }
titig 2:a98660025857 24
titig 2:a98660025857 25 wait_ms(500);
titig 0:c7ce501d534b 26 }
titig 2:a98660025857 27 }