aa
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "Motor.h" 00003 Serial pc(USBTX, USBRX); 00004 Motor myMotor(PA_1, PA_0); 00005 Motor isMotor(PB_0, PA_4); 00006 Motor miMotor(PF_0, PA_3); 00007 Motor hisMotor(PA_7, PA_5); 00008 char incoming; 00009 float wx = 0; 00010 float wy = 0; 00011 float wz = 0; 00012 float wp = 0; 00013 00014 int main() { 00015 00016 pc.baud(9600); 00017 while(1){ 00018 if(pc.readable()) { 00019 incoming = pc.getc(); 00020 switch(incoming) { 00021 case 'a': 00022 wx = wx+0.02; 00023 myMotor.speed(wx); 00024 pc.printf("Motor 1 is: %4f\r\n", wx); 00025 break; 00026 case 's': 00027 wx = wx-0.02; 00028 myMotor.speed(wx); 00029 pc.printf("Motor 1 s: %4f\r\n", wx); 00030 break; 00031 00032 case 'd': 00033 wx = 0.0; 00034 myMotor.speed(wx); 00035 pc.printf("Motor 1 is: 4f\r\n", wx); 00036 break; 00037 case 'z': 00038 wy = wy+0.02; 00039 isMotor.speed(wy); 00040 pc.printf("Motor 2 is: %4f\r\n", wy); 00041 break; 00042 case 'x': 00043 wy = wy-0.02; 00044 isMotor.speed(wy); 00045 pc.printf("Motor 2 is: %4f\r\n", wy); 00046 break; 00047 00048 case 'c': 00049 wy = 0.0; 00050 isMotor.speed(wy); 00051 pc.printf("Motor 2 is: %4f \r\n", wy); 00052 break; 00053 case 'f': 00054 wz = wz+0.02; 00055 miMotor.speed(wz); 00056 pc.printf("Motor 3 is: %4f\r\n", wz); 00057 break; 00058 case 'g': 00059 wz = wz-0.02; 00060 miMotor.speed(wz); 00061 pc.printf("Motor 3 is: %4f\r\n", wz); 00062 break; 00063 00064 case 'h': 00065 wz = 0.0; 00066 miMotor.speed(wz); 00067 pc.printf("Motor 3 is: %4f\r\n", wz); 00068 break; 00069 case 'v': 00070 wp = wp+0.02; 00071 hisMotor.speed(wp); 00072 pc.printf("Motor 4 is: %4f\r\n", wp); 00073 break; 00074 case 'b': 00075 wp = wp-0.02; 00076 hisMotor.speed(wp); 00077 pc.printf("Motor 4 is: %4f\r\n", wp); 00078 break; 00079 00080 case 'n': 00081 wp = 0.0; 00082 hisMotor.speed(wp); 00083 pc.printf("Motor 4 is: %4f \r\n", wp); 00084 break; 00085 case 'p': 00086 pc.printf("Motor 1 is: %4f\r\n", wx); 00087 pc.printf("Motor 2 is: %4f \r\n", wy); 00088 pc.printf("Motor 3 is: 4f\r\n", wz); 00089 pc.printf("Motor 4 is: %4f \r\n", wp); 00090 break; 00091 } 00092 } 00093 00094 00095 } 00096 }
Generated on Wed Jul 13 2022 03:55:39 by
1.7.2