thread based dc motor direction

Dependencies:   Motor mbed-rtos mbed

Fork of rtos_basic by mbed official

Committer:
mab5449
Date:
Thu Jan 12 23:21:50 2017 +0000
Revision:
9:dd58814e2dcf
Parent:
8:c1e1db61aee7
Child:
10:dc33cd3f4eb9
Thread::wait is deprecated

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emilmont 1:491820ee784d 1 #include "mbed.h"
emilmont 1:491820ee784d 2
emilmont 1:491820ee784d 3 DigitalOut led1(LED1);
emilmont 1:491820ee784d 4 DigitalOut led2(LED2);
geky 7:8d9919175929 5 Thread thread;
emilmont 1:491820ee784d 6
geky 7:8d9919175929 7 void led2_thread() {
emilmont 1:491820ee784d 8 while (true) {
emilmont 1:491820ee784d 9 led2 = !led2;
mab5449 9:dd58814e2dcf 10 wait(1000);
emilmont 1:491820ee784d 11 }
emilmont 1:491820ee784d 12 }
emilmont 1:491820ee784d 13
emilmont 1:491820ee784d 14 int main() {
geky 7:8d9919175929 15 thread.start(led2_thread);
emilmont 1:491820ee784d 16
emilmont 1:491820ee784d 17 while (true) {
emilmont 1:491820ee784d 18 led1 = !led1;
mab5449 9:dd58814e2dcf 19 wait(500);
emilmont 1:491820ee784d 20 }
emilmont 1:491820ee784d 21 }