MAXS / Mbed 2 deprecated manual_cansat

Dependencies:   mbed

Revision:
0:6fe0fbc55b6f
Child:
1:06b0309330c5
diff -r 000000000000 -r 6fe0fbc55b6f main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Oct 23 08:55:58 2018 +0000
@@ -0,0 +1,69 @@
+#include "mbed.h"
+
+Serial xbee(p13,p14);
+Serial pc(USBTX,USBRX);
+DigitalOut stby(p23);
+DigitalOut A_out(p22);
+DigitalOut B_out(p24);
+PwmOut motor_A(p21);
+PwmOut motor_B(p25);
+
+int main()
+{
+    char data;
+    
+    stby = 1; A_out = 1;B_out = 1;
+    motor_A.period(0.020);
+    motor_B.period(0.020);
+    motor_A.pulsewidth(0.00);
+    motor_B.pulsewidth(0.00);
+    
+    pc.printf("start\n");
+    xbee.printf("start\n");
+    
+    while(1)
+    {
+        if(xbee.readable());
+         {
+            data = xbee.getc();
+         }
+        
+        if(data == 'F')
+         { 
+            motor_A.pulsewidth(0.018);
+            motor_B.pulsewidth(0.018);
+            pc.printf("F:%c",data);
+         }
+             
+        else if(data == 'B')
+         {
+            motor_A.pulsewidth(0.00);
+            motor_B.pulsewidth(0.00);
+            pc.printf("B:%c",data);
+         }
+             
+        else if(data == 'R')
+         {
+            motor_A.pulsewidth(0.018);
+            motor_B.pulsewidth(0.00);
+            pc.printf("R:%c",data);
+         }
+             
+        else if(data == 'L')
+         {
+            motor_A.pulsewidth(0.00);
+            motor_B.pulsewidth(0.018);
+            pc.printf("L:%c",data);
+         }
+            
+        else
+         {   
+            motor_A.pulsewidth(0.00);
+            motor_B.pulsewidth(0.00);
+            pc.printf("N:%c",data);
+         }
+             
+        data = 'N';
+         
+    }
+}