Lee Nam Cheol / Mbed OS lab06-mutex-yes
Revision:
2:20e20cfae75e
Parent:
1:89d23c8072af
Child:
3:1c8ab6d6af18
--- a/main.cpp	Tue Apr 21 12:20:31 2020 +0000
+++ b/main.cpp	Mon Apr 27 08:02:20 2020 +0000
@@ -1,16 +1,14 @@
 #include "mbed.h"
 
-PwmOut servo(PTA1);   //servo = PTA1
+Serial uart_tx(D1, D0);   //D1 = tx, D0 = rx
+DigitalIn sw(D2, PullDown);
 
 int main()
 {
-    float w;
-
-    servo.period(20.0 / 1000.0);    //period = 20ms for SG90 servo
-    while (true) { //500 ~ 2500us for degree 0 to 180
-        for(w = 500; w <= 2500; w += 100) {
-            servo.write(w / (20.0 * 1000.0));
-            thread_sleep_for(1000);
+    while(true) {
+        if(sw == 1) {
+            uart_tx.putc('1');
+            thread_sleep_for(200);
         }
     }
 }
\ No newline at end of file