Mirembe Jean d'Amour / Mbed 2 deprecated ASSIGNMENT_CODES

Dependencies:   mbed

Committer:
titig
Date:
Sun Nov 01 12:21:50 2020 +0000
Revision:
3:a1263051d681
Parent:
2:a98660025857
Child:
4:232f69c6c92c
Once YELLOW light is switched OFF, when the button is switched OFF again, make the YELLOW light ON;

Who changed what in which revision?

UserRevisionLine numberNew 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 3:a1263051d681 19 trafficYellowlight=!pedestrainButton; // Yellow light reamin switched OFF but once button is pressed to be OFF Yellow light will be ON
titig 2:a98660025857 20 }
titig 2:a98660025857 21
titig 2:a98660025857 22 wait_ms(500);
titig 0:c7ce501d534b 23 }
titig 2:a98660025857 24 }