Robert Labuz
/
DISCO-F429ZI_LEDs_Button_1c
1c
Revision 0:50954cecffbf, committed 2017-05-05
- Comitter:
- Robsonik16
- Date:
- Fri May 05 19:42:02 2017 +0000
- Commit message:
- a
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 50954cecffbf main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri May 05 19:42:02 2017 +0000 @@ -0,0 +1,44 @@ +#include "mbed.h" + +DigitalOut led_green(LED1); +DigitalOut led_red(LED2); + +InterruptIn user_button(USER_BUTTON); + +float delay_on = 0.2; +float delay_off = 1.0; +enum led {LED_1,LED_2}; +enum led eLed=LED_2; +void button_pressed() +{ + eLed=LED_1; + delay_on = 0.2; + delay_off = 0.2; +} + +void button_released() +{ + eLed=LED_2; + delay_on = 0.2; + delay_off = 0.2; +} + +int main() +{ + user_button.rise(&button_pressed); + user_button.fall(&button_released); + + while(1) { + // LEDs are ON + if(eLed == LED_1) + led_green = 1; + else + led_red = 1; + wait(delay_on); + // LEDs are OFF + + led_green = 0; + led_red = 0; + wait(delay_off); + } +}
diff -r 000000000000 -r 50954cecffbf mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri May 05 19:42:02 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4336505e4b1c \ No newline at end of file