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:
- 2:20e20cfae75e
- Parent:
- 1:89d23c8072af
- Child:
- 3:2788b2e18904
diff -r 89d23c8072af -r 20e20cfae75e main.cpp
--- 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