Mirembe Jean d'Amour / Mbed 2 deprecated ASSIGNMENT_CODES

Dependencies:   mbed

main.cpp

Committer:
titig
Date:
2020-11-01
Revision:
6:2aa20d4e28e4
Parent:
5:0225e0fdab62

File content as of revision 6:2aa20d4e28e4:

#include "mbed.h"                      // Including Mbed Libraries
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
    trafficRedlight=0;        //Initialize Red light to OFF
    while(1) 
    {
        
        if(pedestrainButton & trafficYellowlight){
            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=0;    //switch OFF yellow light
            trafficRedlight=1;      //switch ON Red light   
             }
             if(!trafficYellowlight){
                 trafficYellowlight=!pedestrainButton;    // Yellow light reamin switched OFF but once button is pressed to be OFF Yellow light will be ON
                 trafficRedlight=!trafficYellowlight;    // switching ON Red light once Yellow light is OFF
             }
        
             wait_ms(500);
               }
}