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
main.cpp
- Committer:
- noutram
- Date:
- 2017-10-23
- Revision:
- 1:e84a51c98d75
- Parent:
- 0:397b84c74d17
- Child:
- 2:4cf6f5cba257
File content as of revision 1:e84a51c98d75:
#include "mbed.h"
#include "SWPoll.hpp"
#define N 1000000
#define RELEASED 0
#define PRESSED 1
//Function prototypes
void task1();
void task2();
//Hardware objects
DigitalOut red_led(PE_15); //CountUp is in its critical section
DigitalOut yellow_led(PB_10); //CountDown is in its critical section
DigitalOut green_led(PB_11); //counter != 0
DigitalOut onboardLED(LED1);
DigitalIn button(USER_BUTTON);
DigitalIn sw1(PE_12);
DigitalIn sw2(PE_14);
SWPoll switch1(sw1, red_led);
SWPoll switch2(sw2, green_led);
//LOOK AT SWPoll.hpp for the definition of the SWPoll class
int main() {
//Main uses a Timer
yellow_led = 1;
Timer t;
//Now loop forever
t.start();
while(1) {
//Flash the yellow on the "main thread"
if (t.read_ms() >= 500) {
yellow_led = !yellow_led;
t.reset();
}
switch1.poll();
switch2.poll();
};
}
