init

Dependencies:   mbed

Fork of 仓库 by Keegan Hu

Files at this revision

API Documentation at this revision

Comitter:
glintligo
Date:
Thu May 17 08:29:35 2018 +0000
Parent:
8:d5e340a59c71
Commit message:
fasdf;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Mar 19 03:32:21 2018 +0000
+++ b/main.cpp	Thu May 17 08:29:35 2018 +0000
@@ -14,11 +14,25 @@
 DigitalIn ref(PA_12);
 DigitalOut LED(PC_13);
 
+
+//   PA_6   P3  从下往上第二个舵机   1ms   往后倒90度   1.5ms   往后倒45度    2ms 笔直
+//   PB_1   P6  从下往上第四个舵机   2ms  张开      1.5ms  中间  1ms  完全合上
+//   PA_7   P4  从下往上第一个舵机   1.5ms   从正前方看往右偏45度  1ms    正中间   2ms 右偏度
+//   PB_0   P5  从下往上第三个舵机    1.5 中间      1  往后45度  2  往前45
+
+
+PwmOut mypwm1(PA_7);
+PwmOut mypwm2(PA_6);
+PwmOut mypwm3(PB_0);
+PwmOut mypwm4(PB_1);
+
+
+
 int main(void) {
     ser2usb.printf("starting\r\n");
     
     // 选定与 esp8266 相连接的串口,WiFi 名称和密码
-    Esp8266 client(PA_9, PA_10, "iot_b827eb91bf24", "b827ebc4ea71");// 参数分别为 TX pin / RX pin / SSID / Password
+    Esp8266 client(PA_9, PA_10, "iot_b827ebd838be", "ab087c9e");// 参数分别为 TX pin / RX pin / SSID / Password
 
     //声明所有的传感器,每行一个,每个由名字、单位两部分组成,最后一行必须为空指针作为结尾
     const char* sensors[][2] = {
@@ -51,8 +65,38 @@
             ser2usb.printf("Received CMD %s %s\r\n", actuator_name, control_value);
             //判断哪个执行器收到命令
             if(strcmp(actuator_name, "led")==0){
-                LED = atoi(control_value);
-            }
+                mypwm1.period_ms(20);
+                mypwm2.period_ms(20);
+                mypwm3.period_ms(20);
+                mypwm4.period_ms(20);
+                
+                
+                mypwm1.pulsewidth(0.001);
+                wait(0.5);
+                mypwm1.pulsewidth(0.0015);
+                wait(0.5);
+                mypwm1.pulsewidth(0.002);
+                wait(0.5);
+                mypwm1.pulsewidth(0.0015);
+                wait(0.5);
+                mypwm1.pulsewidth(0.001);
+                wait(0.5);
+                
+                mypwm3.pulsewidth(0.001);
+                wait(0.5);
+                mypwm3.pulsewidth(0.0015);
+                wait(0.5);
+                
+                mypwm4.pulsewidth(0.001);
+                wait(0.5);
+                mypwm4.pulsewidth(0.0015);
+                wait(0.5);
+                mypwm4.pulsewidth(0.002);
+                wait(0.5);
+                
+                 mypwm3.pulsewidth(0.0015);
+                wait(0.5);
+                }
         }
         
         bool reflection = ref;