Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Task330_polling by
Diff: main.cpp
- Revision:
- 1:e84a51c98d75
- Parent:
- 0:397b84c74d17
- Child:
- 2:4cf6f5cba257
--- a/main.cpp Mon Oct 23 09:37:46 2017 +0000 +++ b/main.cpp Mon Oct 23 09:47:16 2017 +0000 @@ -22,7 +22,7 @@ SWPoll switch1(sw1, red_led); SWPoll switch2(sw2, green_led); - +//LOOK AT SWPoll.hpp for the definition of the SWPoll class int main() { @@ -45,38 +45,3 @@ } -//Thread 1 - polling sw1 and controlling the red LED -void task1() -{ - //Loop forever - while(1) { - //Spin on sw1 - while (sw1 == RELEASED) {}; - //Allow short delay for switch bounce - Thread::wait(200); - //Spin again on sw1 - while (sw1 == PRESSED) {}; - //Toggle LED - red_led = !red_led; - //Again, wait for switch bounce - Thread::wait(200); - } -} - -//Thread 2 - polling sw2 and controlling the green LED -void task2() -{ - //Loop forever - while(1) { - //Spin on sw2 - while (sw2 == RELEASED) {}; - //Allow short delay for switch bounce - Thread::wait(200); - //Spin again on sw2 - while (sw2 == PRESSED) {}; - //Toggle LED - green_led = !green_led; - //Again, wait for switch bounce - Thread::wait(200); - } -}