MAXS / Mbed 2 deprecated manual_cansat

Dependencies:   mbed

main.cpp

Committer:
hswell3221
Date:
2018-10-25
Revision:
1:06b0309330c5
Parent:
0:6fe0fbc55b6f
Child:
2:2580959cb1f9

File content as of revision 1:06b0309330c5:

#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.015);
            motor_B.pulsewidth(0.015);
            pc.printf("F:%c",data);
         }*/
             
        if(data == 'A')
         {
            motor_A.pulsewidth(0.018);
            motor_B.pulsewidth(0.018);
            pc.printf("A:%c",data);
         }
             
        if(data == 'R')
         {
            motor_A.pulsewidth(0.020);
            motor_B.pulsewidth(0.00);
            pc.printf("R:%c",data);
         }
             
        if(data == 'L')
         {
            motor_A.pulsewidth(0.00);
            motor_B.pulsewidth(0.018);
            pc.printf("L:%c",data);
         }
            
        if(data == 'N')
         {   
            motor_A.pulsewidth(0.00);
            motor_B.pulsewidth(0.00);
            pc.printf("N:%c",data);
         }
             
        //data = 'N';
         
    }
}