MAXS / Mbed 2 deprecated manual_cansat

Dependencies:   mbed

Committer:
hswell3221
Date:
Thu Oct 25 12:43:37 2018 +0000
Revision:
1:06b0309330c5
Parent:
0:6fe0fbc55b6f
Child:
2:2580959cb1f9
1025;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hswell3221 0:6fe0fbc55b6f 1 #include "mbed.h"
hswell3221 0:6fe0fbc55b6f 2
hswell3221 0:6fe0fbc55b6f 3 Serial xbee(p13,p14);
hswell3221 0:6fe0fbc55b6f 4 Serial pc(USBTX,USBRX);
hswell3221 0:6fe0fbc55b6f 5 DigitalOut stby(p23);
hswell3221 0:6fe0fbc55b6f 6 DigitalOut A_out(p22);
hswell3221 0:6fe0fbc55b6f 7 DigitalOut B_out(p24);
hswell3221 0:6fe0fbc55b6f 8 PwmOut motor_A(p21);
hswell3221 0:6fe0fbc55b6f 9 PwmOut motor_B(p25);
hswell3221 0:6fe0fbc55b6f 10
hswell3221 0:6fe0fbc55b6f 11 int main()
hswell3221 0:6fe0fbc55b6f 12 {
hswell3221 0:6fe0fbc55b6f 13 char data;
hswell3221 0:6fe0fbc55b6f 14
hswell3221 0:6fe0fbc55b6f 15 stby = 1; A_out = 1;B_out = 1;
hswell3221 0:6fe0fbc55b6f 16 motor_A.period(0.020);
hswell3221 0:6fe0fbc55b6f 17 motor_B.period(0.020);
hswell3221 0:6fe0fbc55b6f 18 motor_A.pulsewidth(0.00);
hswell3221 0:6fe0fbc55b6f 19 motor_B.pulsewidth(0.00);
hswell3221 0:6fe0fbc55b6f 20
hswell3221 0:6fe0fbc55b6f 21 pc.printf("start\n");
hswell3221 0:6fe0fbc55b6f 22 xbee.printf("start\n");
hswell3221 0:6fe0fbc55b6f 23
hswell3221 0:6fe0fbc55b6f 24 while(1)
hswell3221 0:6fe0fbc55b6f 25 {
hswell3221 1:06b0309330c5 26 if(xbee.readable())
hswell3221 0:6fe0fbc55b6f 27 {
hswell3221 0:6fe0fbc55b6f 28 data = xbee.getc();
hswell3221 0:6fe0fbc55b6f 29 }
hswell3221 0:6fe0fbc55b6f 30
hswell3221 1:06b0309330c5 31 /*if(data == 'F')
hswell3221 0:6fe0fbc55b6f 32 {
hswell3221 1:06b0309330c5 33 motor_A.pulsewidth(0.015);
hswell3221 1:06b0309330c5 34 motor_B.pulsewidth(0.015);
hswell3221 1:06b0309330c5 35 pc.printf("F:%c",data);
hswell3221 1:06b0309330c5 36 }*/
hswell3221 1:06b0309330c5 37
hswell3221 1:06b0309330c5 38 if(data == 'A')
hswell3221 1:06b0309330c5 39 {
hswell3221 0:6fe0fbc55b6f 40 motor_A.pulsewidth(0.018);
hswell3221 0:6fe0fbc55b6f 41 motor_B.pulsewidth(0.018);
hswell3221 1:06b0309330c5 42 pc.printf("A:%c",data);
hswell3221 0:6fe0fbc55b6f 43 }
hswell3221 0:6fe0fbc55b6f 44
hswell3221 1:06b0309330c5 45 if(data == 'R')
hswell3221 0:6fe0fbc55b6f 46 {
hswell3221 1:06b0309330c5 47 motor_A.pulsewidth(0.020);
hswell3221 0:6fe0fbc55b6f 48 motor_B.pulsewidth(0.00);
hswell3221 0:6fe0fbc55b6f 49 pc.printf("R:%c",data);
hswell3221 0:6fe0fbc55b6f 50 }
hswell3221 0:6fe0fbc55b6f 51
hswell3221 1:06b0309330c5 52 if(data == 'L')
hswell3221 0:6fe0fbc55b6f 53 {
hswell3221 0:6fe0fbc55b6f 54 motor_A.pulsewidth(0.00);
hswell3221 0:6fe0fbc55b6f 55 motor_B.pulsewidth(0.018);
hswell3221 0:6fe0fbc55b6f 56 pc.printf("L:%c",data);
hswell3221 0:6fe0fbc55b6f 57 }
hswell3221 0:6fe0fbc55b6f 58
hswell3221 1:06b0309330c5 59 if(data == 'N')
hswell3221 0:6fe0fbc55b6f 60 {
hswell3221 0:6fe0fbc55b6f 61 motor_A.pulsewidth(0.00);
hswell3221 0:6fe0fbc55b6f 62 motor_B.pulsewidth(0.00);
hswell3221 0:6fe0fbc55b6f 63 pc.printf("N:%c",data);
hswell3221 0:6fe0fbc55b6f 64 }
hswell3221 0:6fe0fbc55b6f 65
hswell3221 1:06b0309330c5 66 //data = 'N';
hswell3221 0:6fe0fbc55b6f 67
hswell3221 0:6fe0fbc55b6f 68 }
hswell3221 0:6fe0fbc55b6f 69 }