JuHwan Kim / Mbed 2 deprecated 20170607_flop_tank_test

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
mcthemax
Date:
Tue Jul 10 01:04:02 2018 +0000
Commit message:
s

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jul 10 01:04:02 2018 +0000
@@ -0,0 +1,70 @@
+#include "mbed.h"
+
+Serial pc(USBTX, USBRX);
+
+PwmOut motor1(p21);
+PwmOut motor2(p22);
+
+int motor1_width = 1500;
+int motor2_width = 1500;
+
+unsigned char input_pc = 0;
+
+int main() {
+    motor1.period_ms(20);
+    motor2.period_ms(20);
+    while(1) {
+        if(pc.readable())
+        {
+            input_pc = pc.getc();
+            
+            if(input_pc == 'w')
+            {
+                motor1_width = 1500;
+            }
+            else if(input_pc == 'e')
+            {
+                motor1_width+=1;
+            }
+            else if(input_pc == 'q')
+            {
+                motor1_width-=1;
+            }
+            else if(input_pc == 'd')
+            {
+                motor1_width+=10;
+            }
+            else if(input_pc == 'a')
+            {
+                motor1_width-=10;
+            }
+            else if(input_pc == 't')
+            {
+                motor2_width = 1500;
+            }
+            else if(input_pc == 'y')
+            {
+                motor2_width+=1;
+            }
+            else if(input_pc == 'r')
+            {
+                motor2_width-=1;
+            }
+            else if(input_pc == 'h')
+            {
+                motor2_width+=10;
+            }
+            else if(input_pc == 'f')
+            {
+                motor2_width-=10;
+            }
+        }
+        
+        pc.printf("%d  %d\r\n",motor1_width,motor2_width);
+        
+        motor1.pulsewidth_us(motor1_width);
+        motor2.pulsewidth_us(motor2_width);
+        
+        wait(0.01);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Jul 10 01:04:02 2018 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/86740a56073b
\ No newline at end of file