aa

Dependencies:   mbed ForItay

Revision:
0:78be441efc5a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Jun 16 18:48:11 2021 +0000
@@ -0,0 +1,96 @@
+#include "mbed.h"
+#include "Motor.h"
+Serial pc(USBTX, USBRX);
+Motor myMotor(PA_1, PA_0);
+Motor isMotor(PB_0, PA_4);
+Motor miMotor(PF_0, PA_3);
+Motor hisMotor(PA_7, PA_5);
+char incoming;
+float wx = 0;
+float wy = 0;
+float wz = 0;
+float wp = 0;
+
+int main() {
+
+    pc.baud(9600);
+    while(1){
+        if(pc.readable()) {
+            incoming = pc.getc();
+            switch(incoming) {
+                case 'a':
+                    wx = wx+0.02;
+                    myMotor.speed(wx);
+                    pc.printf("Motor 1 is:  %4f\r\n", wx);
+                    break;
+                case 's':
+                    wx = wx-0.02;
+                     myMotor.speed(wx);
+                     pc.printf("Motor 1 s:  %4f\r\n", wx);
+                    break;
+                    
+                case 'd':
+                    wx = 0.0;
+                    myMotor.speed(wx);
+                    pc.printf("Motor 1 is: 4f\r\n", wx);
+                    break;
+                case 'z':
+                    wy = wy+0.02;
+                    isMotor.speed(wy);
+                    pc.printf("Motor 2 is:  %4f\r\n", wy);
+                    break;
+                case 'x':
+                    wy = wy-0.02;
+                     isMotor.speed(wy);
+                     pc.printf("Motor 2 is:  %4f\r\n", wy);
+                    break;
+                    
+                case 'c':
+                    wy = 0.0;
+                    isMotor.speed(wy);
+                    pc.printf("Motor 2  is:  %4f \r\n", wy);
+                    break;
+                case 'f':
+                    wz = wz+0.02;
+                    miMotor.speed(wz);
+                    pc.printf("Motor 3 is:  %4f\r\n", wz);
+                    break;
+                case 'g':
+                    wz = wz-0.02;
+                     miMotor.speed(wz);
+                     pc.printf("Motor 3 is:  %4f\r\n", wz);
+                    break;
+                    
+                case 'h':
+                    wz = 0.0;
+                    miMotor.speed(wz);
+                    pc.printf("Motor 3 is: %4f\r\n", wz);
+                    break;
+                case 'v':
+                    wp = wp+0.02;
+                    hisMotor.speed(wp);
+                    pc.printf("Motor 4 is:  %4f\r\n", wp);
+                    break;
+                case 'b':
+                    wp = wp-0.02;
+                     hisMotor.speed(wp);
+                     pc.printf("Motor 4 is:  %4f\r\n", wp);
+                    break;
+                    
+                case 'n':
+                    wp = 0.0;
+                    hisMotor.speed(wp);
+                    pc.printf("Motor 4 is:  %4f \r\n", wp);
+                    break;
+                case 'p':
+                    pc.printf("Motor 1 is:  %4f\r\n", wx);
+                    pc.printf("Motor 2  is:  %4f \r\n", wy);
+                    pc.printf("Motor 3 is: 4f\r\n", wz);
+                    pc.printf("Motor 4 is:  %4f \r\n", wp);
+                    break;
+                }           
+        }
+
+          
+        }
+}