push button
Dependencies: mbed BSP_DISCO_F413ZH
main.cpp
00001 #include "mbed.h" 00002 DigitalOut trafficYellowlight(p5); 00003 DigitalIn pedestrainButton(p6); 00004 int main() { 00005 trafficYellowlight=1; 00006 while(1) 00007 { 00008 if(pedestrainButton&trafficYellowlight){ 00009 int counter=0; 00010 printf("counter is now%d\n",counter); 00011 // blink for 5 seconds 00012 while(counter<10){ 00013 counter+=1; 00014 trafficYellowlight=!trafficYellowlight; 00015 wait_ms(500);//delay of 1 second 00016 } 00017 trafficYellowlight=0;//switch off 00018 } 00019 if(!trafficYellowlight){ 00020 trafficYellowlight=!pedestrainButton; 00021 } 00022 00023 wait_ms(500); 00024 } 00025 }
Generated on Thu Jul 21 2022 00:29:37 by 1.7.2