LED blinking using button on STM32F0 Discovery.
Dependencies: mbed
Revision 3:67e70777bc5d, committed 2015-05-12
- Comitter:
- Foxnec
- Date:
- Tue May 12 09:09:31 2015 +0000
- Parent:
- 2:da8f8b14f387
- Commit message:
- Changes to comments
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Mar 23 13:20:48 2015 +0000 +++ b/main.cpp Tue May 12 09:09:31 2015 +0000 @@ -23,12 +23,12 @@ /* Function prototypes -----------------------------------------------------------*/ /* Variables ---------------------------------------------------------------------*/ -bool press = false; // boolean value, where you can find if was the button pressed +bool press = false; // boolean value, says if was the button pressed //mbed - initialization of peripherals -InterruptIn button(PA_0); // inicialize button on STM32F0 discovery -DigitalOut blue(PC_8); // inicialize blue LED on STM32F0 discovery -DigitalOut green(PC_9); // inicialize green LED on STM32F0 discovery +InterruptIn button(PA_0); // initialize button on STM32F0 discovery +DigitalOut blue(PC_8); // initialize blue LED on STM32F0 discovery +DigitalOut green(PC_9); // initialize green LED on STM32F0 discovery /* Functions----------------------------------------------------------------------*/ @@ -41,7 +41,7 @@ *******************************************************************************/ void pressed() { - if (press == false){ // variable prees was false (button wasn't pressed yet) + if (press == false){ // variable press was false (button wasn't pressed yet) press = true; // press is true (button was pressed) }else{ // variable press was true press = false; // press is false @@ -61,17 +61,17 @@ green=0; // green LED is on button.fall(&pressed); // button was pressed, call function pressed - while (1) { // infinity loop - green = !green; // inverse value of green LED + while (1) { // infinite loop + green = !green; // inverts the value of green LED if (press == false){ // button wasn't pressed - blue=!green; // value of blue LED is iverse to green LED + blue=!green; // the value of blue LED is inverse to green LED wait(0.4); // wait 400 ms }else{ // button was pressed - blue=green; // value of blue LED is same like value of green LED + blue=green; // the value of blue LED is same like the value of green LED wait(0.2); // wait 200 ms - green = !green; // inverse value of green LED + green = !green; // inverts value of green LED wait(0.2); // wait 200 ms - green = !green; // inverse value of green LED + green = !green; // inverts value of green LED wait(0.2); // wait 200 ms } }