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.
Diff: main.cpp
- Revision:
- 0:d69424c893b6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Jul 13 06:19:53 2020 +0000
@@ -0,0 +1,40 @@
+#include "mbed.h"
+#include "rtos.h"
+
+DigitalOut led1(p18);
+DigitalOut led2(p19);
+DigitalOut led3(p20);
+
+Semaphore slot(1);
+
+void Led(void const *name){
+ while(true){
+ slot.wait();
+ printf("優先度:%s\n\r",name);
+ if(name=="-1"){
+ led1 = !led1;
+ ThisThread::sleep_for(100);
+ led1 = !led1;
+ }else if(name=="0"){
+ led2 = !led2;
+ ThisThread::sleep_for(100);
+ led2 = !led2;
+ }else if(name=="1"){
+ led3 = !led3;
+ ThisThread::sleep_for(100);
+ led3 = !led3;
+ }
+ slot.release();
+ }
+ }
+
+
+int main(){
+ Thread thread1(Led,(void*)"-1",osPriorityBelowNormal);
+ Thread thread2(Led,(void*)"1",osPriorityAboveNormal);
+
+ Led((void*)"0");
+ }
+
+
+
\ No newline at end of file