push button
Dependencies: mbed BSP_DISCO_F413ZH
Diff: main.cpp
- Revision:
- 0:f6f71c16c132
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Nov 01 09:34:00 2020 +0000 @@ -0,0 +1,25 @@ +#include "mbed.h" +DigitalOut trafficYellowlight(p5); +DigitalIn pedestrainButton(p6); +int main() { + trafficYellowlight=1; + 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(500);//delay of 1 second + } + trafficYellowlight=0;//switch off + } + if(!trafficYellowlight){ + trafficYellowlight=!pedestrainButton; + } + + wait_ms(500); + } +}