linear actuator

Dependencies:   Motor PinDetect mbed

Fork of xbee_robot by Shubhojit Chattopadhyay

main.cpp

Committer:
buntyshubho
Date:
2011-02-27
Revision:
0:4b7f01607612
Child:
1:57f1410e9614

File content as of revision 0:4b7f01607612:

//Robot Unit with the Xbee module

#include "mbed.h"
#include "Motor.h"

Serial xbee2(p9, p10);
DigitalOut rst2(p8);

Serial pc(USBTX, USBRX);

DigitalOut myled2(LED3);
DigitalOut myled1(LED4);

Motor m1(p23, p11, p12); // pwm, fwd, rev //lEFT MOTOR
Motor m2(p22, p14, p15); // pwm, fwd, rev //rIGHT MOTOR

Motor m3(p23, p12, p11); // pwm, rev, fwd 
Motor m4(p22, p15, p14); // pwm, rev, fwd
int main() {
    char temp = '0';

    // reset the xbees (at least 200ns)
   // rst1 = 0;
    rst2 = 0;
    wait_ms(1); 
    //rst1 = 1;
    rst2 = 1;
    wait_ms(1); 
 
     for (float s= -1.0; s < 1.0 ; s += 0.01) {
     while(1) {
     temp = xbee2.getc();
     if(temp == 'C'){  //FORWARD
        m1.speed(s); 
        m2.speed(s);
        wait(0.02);
        }
        
         if(temp == 'D'){ //REVERSE
        m3.speed(s); 
        m4.speed(s);
        wait(0.02);
        }
        
                myled1 = 1;
                wait_ms(1);
                myled1 = 0;
                myled2 =1;
    
   } 
  }  
}