Because the light of four LED flows, the button is stopped pushing and seen at the decided position. Do you make it to good?
main.cpp
00001 /* 00002 Name: Roulette 00003 Function: IntteruptIn, BusOut 00004 Parts: Push Button 00005 */ 00006 00007 #include "mbed.h" 00008 00009 InterruptIn button(p5); // Push Button 00010 BusOut myleds(LED1, LED2, LED3, LED4); 00011 int save; 00012 00013 void blink() { 00014 save = myleds; 00015 myleds = 0; wait(0.3); 00016 myleds = save; wait(0.3); 00017 myleds = 0; wait(0.3); 00018 myleds = save; wait(0.3); 00019 myleds = 0; wait(0.3); 00020 myleds = save; wait(0.3); 00021 myleds = 0; wait(3); 00022 } 00023 00024 int main() { 00025 button.rise(&blink); 00026 while(true) { 00027 myleds = 1; wait(0.1); 00028 myleds = 2; wait(0.1); 00029 myleds = 4; wait(0.1); 00030 myleds = 8; wait(0.1); 00031 } 00032 }
Generated on Wed Jul 20 2022 13:55:04 by 1.7.2