A classy affair
Dependencies: mbed mbed-rtos ShiftReg TextLCD
main.cpp@0:c63c0359492d, 2019-02-25 (annotated)
- Committer:
- mwthewsey
- Date:
- Mon Feb 25 10:36:02 2019 +0000
- Revision:
- 0:c63c0359492d
- Child:
- 1:241551e24735
Thread testing code;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mwthewsey | 0:c63c0359492d | 1 | #include "mbed.h" |
mwthewsey | 0:c63c0359492d | 2 | #include "rtos.h" //Real Time Operating System. https://os.mbed.com/handbook/RTOS |
mwthewsey | 0:c63c0359492d | 3 | |
mwthewsey | 0:c63c0359492d | 4 | DigitalOut myled(LED1); |
mwthewsey | 0:c63c0359492d | 5 | DigitalOut myled2(LED2); |
mwthewsey | 0:c63c0359492d | 6 | Thread thread; |
mwthewsey | 0:c63c0359492d | 7 | |
mwthewsey | 0:c63c0359492d | 8 | |
mwthewsey | 0:c63c0359492d | 9 | void led2_thread() { |
mwthewsey | 0:c63c0359492d | 10 | while(true){ |
mwthewsey | 0:c63c0359492d | 11 | myled2 = !myled2; |
mwthewsey | 0:c63c0359492d | 12 | Thread::wait(1000); |
mwthewsey | 0:c63c0359492d | 13 | } |
mwthewsey | 0:c63c0359492d | 14 | } |
mwthewsey | 0:c63c0359492d | 15 | |
mwthewsey | 0:c63c0359492d | 16 | |
mwthewsey | 0:c63c0359492d | 17 | int main() { |
mwthewsey | 0:c63c0359492d | 18 | thread.start(led2_thread); |
mwthewsey | 0:c63c0359492d | 19 | while(1) { |
mwthewsey | 0:c63c0359492d | 20 | myled = 1; // LED is ON |
mwthewsey | 0:c63c0359492d | 21 | wait(0.2); // 200 ms |
mwthewsey | 0:c63c0359492d | 22 | myled = 0; // LED is OFF |
mwthewsey | 0:c63c0359492d | 23 | wait(1.0); // 1 sec |
mwthewsey | 0:c63c0359492d | 24 | } |
mwthewsey | 0:c63c0359492d | 25 | } |