Robot code

Dependencies:   mbed

Committer:
ikhorosh
Date:
Thu Oct 13 03:06:59 2011 +0000
Revision:
0:c8a510f695d2

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ikhorosh 0:c8a510f695d2 1 #include "mbed.h"
ikhorosh 0:c8a510f695d2 2
ikhorosh 0:c8a510f695d2 3 Serial xbee1(p9, p10);
ikhorosh 0:c8a510f695d2 4 DigitalOut rst1(p11);
ikhorosh 0:c8a510f695d2 5
ikhorosh 0:c8a510f695d2 6 DigitalOut rev(p22);
ikhorosh 0:c8a510f695d2 7 DigitalOut fwd(p20);
ikhorosh 0:c8a510f695d2 8 DigitalOut Led1(LED1);
ikhorosh 0:c8a510f695d2 9 DigitalOut Led2(LED2);
ikhorosh 0:c8a510f695d2 10
ikhorosh 0:c8a510f695d2 11 PwmOut pwmout(p21);
ikhorosh 0:c8a510f695d2 12
ikhorosh 0:c8a510f695d2 13 Serial pc(USBTX, USBRX);
ikhorosh 0:c8a510f695d2 14
ikhorosh 0:c8a510f695d2 15 int main() {
ikhorosh 0:c8a510f695d2 16
ikhorosh 0:c8a510f695d2 17 rst1 = 0; //Set reset pin to 0
ikhorosh 0:c8a510f695d2 18 wait(.5);
ikhorosh 0:c8a510f695d2 19 rst1 = 1; //Set reset pin to 1
ikhorosh 0:c8a510f695d2 20 int X = 0;
ikhorosh 0:c8a510f695d2 21 wait(.5);
ikhorosh 0:c8a510f695d2 22 pc.printf("starting rec");
ikhorosh 0:c8a510f695d2 23 rev = 1;
ikhorosh 0:c8a510f695d2 24 fwd = 0;
ikhorosh 0:c8a510f695d2 25 char b = 'c';
ikhorosh 0:c8a510f695d2 26 while(1) {
ikhorosh 0:c8a510f695d2 27 if(xbee1.readable()) {
ikhorosh 0:c8a510f695d2 28 char X = xbee1.getc(); //XBee read
ikhorosh 0:c8a510f695d2 29 wait(.25);
ikhorosh 0:c8a510f695d2 30 pc.printf("b = %f", X/100.0);
ikhorosh 0:c8a510f695d2 31 pwmout = X/100.0;
ikhorosh 0:c8a510f695d2 32 }
ikhorosh 0:c8a510f695d2 33 }
ikhorosh 0:c8a510f695d2 34 }