![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
none
Fork of thread-example2 by
Revision 1:82ceca58478b, committed 2018-01-18
- Comitter:
- edwinkad
- Date:
- Thu Jan 18 17:25:58 2018 +0000
- Parent:
- 0:83abbbeb9a3d
- Commit message:
- lol
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed-os.lib | Show annotated file Show diff for this revision Revisions of this file |
diff -r 83abbbeb9a3d -r 82ceca58478b main.cpp --- a/main.cpp Sat Jan 13 18:26:10 2018 +0000 +++ b/main.cpp Thu Jan 18 17:25:58 2018 +0000 @@ -5,28 +5,38 @@ // Variable for a second thread Thread thread; +volatile int speed; -DigitalOut ledA(LED1); // Red LED -DigitalOut ledB(LED2); // Green LED +DigitalOut ledR(LED1); // Red LED +//DigitalOut ledG(LED2); // Green LED +//DigitalOut ledB(LED3); // Blue LED + +Serial pc(USBTX, USBRX); // tx, rx // This method is run in the second thread -void ledB_thread() { +void led_default() { while (true) { - Thread::wait(250); - ledB = !ledB; + Thread::wait(speed); + ledR = !ledR; } } // This is the main thread int main (void) { - ledA = 1 ; // off - ledB = 1 ; // off - + char c; + speed=250; + ledR=1; + thread.start(callback(led_default)); + while(1) { + pc.printf("\npress f or s>"); + //ledR_thread(speed); + c = pc.getc(); + if (c=='f'){ + speed-=10; + }else if(c=='s'){ + speed+=10; + } // start the second thread - thread.start(callback(ledB_thread)); - - while (true) { - Thread::wait(400); - ledA = !ledA; } } +
diff -r 83abbbeb9a3d -r 82ceca58478b mbed-os.lib --- a/mbed-os.lib Sat Jan 13 18:26:10 2018 +0000 +++ b/mbed-os.lib Thu Jan 18 17:25:58 2018 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-os/#eca67ca7dafab4ef70c21e2463b541132d0dd691 +https://github.com/ARMmbed/mbed-os/#96d9a00d0a1d25095b330095fa81c40f7741777c