aa

Dependencies:   mbed ForItay

Committer:
noamnahum
Date:
Wed Jun 16 18:48:11 2021 +0000
Revision:
0:78be441efc5a
for itay; a

Who changed what in which revision?

UserRevisionLine numberNew contents of line
noamnahum 0:78be441efc5a 1 #include "mbed.h"
noamnahum 0:78be441efc5a 2 #include "Motor.h"
noamnahum 0:78be441efc5a 3 Serial pc(USBTX, USBRX);
noamnahum 0:78be441efc5a 4 Motor myMotor(PA_1, PA_0);
noamnahum 0:78be441efc5a 5 Motor isMotor(PB_0, PA_4);
noamnahum 0:78be441efc5a 6 Motor miMotor(PF_0, PA_3);
noamnahum 0:78be441efc5a 7 Motor hisMotor(PA_7, PA_5);
noamnahum 0:78be441efc5a 8 char incoming;
noamnahum 0:78be441efc5a 9 float wx = 0;
noamnahum 0:78be441efc5a 10 float wy = 0;
noamnahum 0:78be441efc5a 11 float wz = 0;
noamnahum 0:78be441efc5a 12 float wp = 0;
noamnahum 0:78be441efc5a 13
noamnahum 0:78be441efc5a 14 int main() {
noamnahum 0:78be441efc5a 15
noamnahum 0:78be441efc5a 16 pc.baud(9600);
noamnahum 0:78be441efc5a 17 while(1){
noamnahum 0:78be441efc5a 18 if(pc.readable()) {
noamnahum 0:78be441efc5a 19 incoming = pc.getc();
noamnahum 0:78be441efc5a 20 switch(incoming) {
noamnahum 0:78be441efc5a 21 case 'a':
noamnahum 0:78be441efc5a 22 wx = wx+0.02;
noamnahum 0:78be441efc5a 23 myMotor.speed(wx);
noamnahum 0:78be441efc5a 24 pc.printf("Motor 1 is: %4f\r\n", wx);
noamnahum 0:78be441efc5a 25 break;
noamnahum 0:78be441efc5a 26 case 's':
noamnahum 0:78be441efc5a 27 wx = wx-0.02;
noamnahum 0:78be441efc5a 28 myMotor.speed(wx);
noamnahum 0:78be441efc5a 29 pc.printf("Motor 1 s: %4f\r\n", wx);
noamnahum 0:78be441efc5a 30 break;
noamnahum 0:78be441efc5a 31
noamnahum 0:78be441efc5a 32 case 'd':
noamnahum 0:78be441efc5a 33 wx = 0.0;
noamnahum 0:78be441efc5a 34 myMotor.speed(wx);
noamnahum 0:78be441efc5a 35 pc.printf("Motor 1 is: 4f\r\n", wx);
noamnahum 0:78be441efc5a 36 break;
noamnahum 0:78be441efc5a 37 case 'z':
noamnahum 0:78be441efc5a 38 wy = wy+0.02;
noamnahum 0:78be441efc5a 39 isMotor.speed(wy);
noamnahum 0:78be441efc5a 40 pc.printf("Motor 2 is: %4f\r\n", wy);
noamnahum 0:78be441efc5a 41 break;
noamnahum 0:78be441efc5a 42 case 'x':
noamnahum 0:78be441efc5a 43 wy = wy-0.02;
noamnahum 0:78be441efc5a 44 isMotor.speed(wy);
noamnahum 0:78be441efc5a 45 pc.printf("Motor 2 is: %4f\r\n", wy);
noamnahum 0:78be441efc5a 46 break;
noamnahum 0:78be441efc5a 47
noamnahum 0:78be441efc5a 48 case 'c':
noamnahum 0:78be441efc5a 49 wy = 0.0;
noamnahum 0:78be441efc5a 50 isMotor.speed(wy);
noamnahum 0:78be441efc5a 51 pc.printf("Motor 2 is: %4f \r\n", wy);
noamnahum 0:78be441efc5a 52 break;
noamnahum 0:78be441efc5a 53 case 'f':
noamnahum 0:78be441efc5a 54 wz = wz+0.02;
noamnahum 0:78be441efc5a 55 miMotor.speed(wz);
noamnahum 0:78be441efc5a 56 pc.printf("Motor 3 is: %4f\r\n", wz);
noamnahum 0:78be441efc5a 57 break;
noamnahum 0:78be441efc5a 58 case 'g':
noamnahum 0:78be441efc5a 59 wz = wz-0.02;
noamnahum 0:78be441efc5a 60 miMotor.speed(wz);
noamnahum 0:78be441efc5a 61 pc.printf("Motor 3 is: %4f\r\n", wz);
noamnahum 0:78be441efc5a 62 break;
noamnahum 0:78be441efc5a 63
noamnahum 0:78be441efc5a 64 case 'h':
noamnahum 0:78be441efc5a 65 wz = 0.0;
noamnahum 0:78be441efc5a 66 miMotor.speed(wz);
noamnahum 0:78be441efc5a 67 pc.printf("Motor 3 is: %4f\r\n", wz);
noamnahum 0:78be441efc5a 68 break;
noamnahum 0:78be441efc5a 69 case 'v':
noamnahum 0:78be441efc5a 70 wp = wp+0.02;
noamnahum 0:78be441efc5a 71 hisMotor.speed(wp);
noamnahum 0:78be441efc5a 72 pc.printf("Motor 4 is: %4f\r\n", wp);
noamnahum 0:78be441efc5a 73 break;
noamnahum 0:78be441efc5a 74 case 'b':
noamnahum 0:78be441efc5a 75 wp = wp-0.02;
noamnahum 0:78be441efc5a 76 hisMotor.speed(wp);
noamnahum 0:78be441efc5a 77 pc.printf("Motor 4 is: %4f\r\n", wp);
noamnahum 0:78be441efc5a 78 break;
noamnahum 0:78be441efc5a 79
noamnahum 0:78be441efc5a 80 case 'n':
noamnahum 0:78be441efc5a 81 wp = 0.0;
noamnahum 0:78be441efc5a 82 hisMotor.speed(wp);
noamnahum 0:78be441efc5a 83 pc.printf("Motor 4 is: %4f \r\n", wp);
noamnahum 0:78be441efc5a 84 break;
noamnahum 0:78be441efc5a 85 case 'p':
noamnahum 0:78be441efc5a 86 pc.printf("Motor 1 is: %4f\r\n", wx);
noamnahum 0:78be441efc5a 87 pc.printf("Motor 2 is: %4f \r\n", wy);
noamnahum 0:78be441efc5a 88 pc.printf("Motor 3 is: 4f\r\n", wz);
noamnahum 0:78be441efc5a 89 pc.printf("Motor 4 is: %4f \r\n", wp);
noamnahum 0:78be441efc5a 90 break;
noamnahum 0:78be441efc5a 91 }
noamnahum 0:78be441efc5a 92 }
noamnahum 0:78be441efc5a 93
noamnahum 0:78be441efc5a 94
noamnahum 0:78be441efc5a 95 }
noamnahum 0:78be441efc5a 96 }