Chalermpong Tubcharoen / Mbed 2 deprecated final_project_mbed

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
makia
Date:
Tue Dec 19 07:53:14 2017 +0000
Parent:
0:264924f590d2
Commit message:
add thread

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Dec 19 07:03:16 2017 +0000
+++ b/main.cpp	Tue Dec 19 07:53:14 2017 +0000
@@ -4,6 +4,7 @@
 Serial pc(USBTX, USBRX); //TX, RX
 DigitalOut led(LED1);
 
+
 double delay = 0.5; // 500 ms
 int tamp = 0; //เอามาดูค่าที่ใช้ทดลองกดปุ่ม
 
@@ -13,10 +14,12 @@
     tamp = tamp + 1 ; 
 }
 
-void released()
-{
-    delay = 0.5; // 500 ms
-    pc.printf("tamp stable = %d " , tamp);
+void led2_thread() {
+    while (true) {
+        led2 = !led2;
+        pc.printf("test thread\n");
+        wait(60);
+    }
 }
 
 int main()
@@ -24,7 +27,8 @@
     // Assign functions to button
     button.fall(&pressed);
     button.rise(&released);
-
+    thread.start(led2_thread);
+    
     while (1) {
         led = !led;
         pc.printf("%d" , tamp);