Felix HARERIMANA / Mbed 2 deprecated DISCO_F413ZH-trafficproject-SOUND

Dependencies:   mbed

main.cpp

Committer:
harerimana
Date:
2020-11-01
Revision:
5:e1afaceb1196
Parent:
4:21c7f1725060
Child:
6:14626bbcb236

File content as of revision 5:e1afaceb1196:

#include "mbed.h"
DigitalOut trafficYellowlight(p7);
DigitalOut trafficRedlight(p9);
DigitalIn pedestrainButton(p8);
int main() {
    trafficYellowlight=1;
    trafficRedlight=0;
    while(1) 
    {
        if(pedestrainButton&trafficYellowlight){
            int counter=0;
            printf("counter is now%d\n",counter);
            // blink for 5 seconds
            while(counter<10){
                counter+=1;
                trafficYellowlight=!trafficYellowlight;
                wait_ms(5000);//delay of 5 second
            }
            trafficYellowlight=0;//switch off
             trafficRedlight=1; // set trafficReslight on
             }
             if(!trafficYellowlight){
              trafficYellowlight=!pedestrainButton; // yellow and red lights are switched opposetely
                 
             }
        
             wait_ms(5000); // wait for 5 second
               }
}