サーボをPCで操作できるやつ

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Tomo1213
Date:
Sat Sep 14 11:23:34 2019 +0000
Commit message:
first commit;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r bc5a282e8a84 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Sep 14 11:23:34 2019 +0000
@@ -0,0 +1,51 @@
+#include "mbed.h"
+
+DigitalOut myled(LED1);
+PwmOut m(PA_9);
+Serial pc(USBTX,USBRX);
+
+#if 1
+int main(){
+    m.period_ms(20);
+    int pw=1500;
+    while(1){
+
+       char input = pc.getc();
+       if(input == 'w'){
+           pw+=50;
+       }else if(input == 's'){
+           pw-=50;
+       }
+       printf("%d\r\n",pw);
+
+       m.pulsewidth_us(pw);
+       
+    }
+}
+#endif
+
+#if 0
+int main(){
+    m.period_ms(20);
+    
+    while(1){
+        m.pulsewidth_us(400);
+        wait(1.5);
+        m.pulsewidth_us(2550);
+        wait(1.5);         
+    }
+}
+#endif
+
+#if 0
+int main(){
+    m.period_ms(20);
+    
+    while(1){
+        m.pulsewidth_us(1000);
+        wait(1.5);
+        m.pulsewidth_us(2000);
+        wait(1.5);         
+    }
+}
+#endif
diff -r 000000000000 -r bc5a282e8a84 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Sep 14 11:23:34 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file