![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
reciever code
Diff: main.cpp
- Revision:
- 0:0a1680d44129
diff -r 000000000000 -r 0a1680d44129 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Oct 30 13:41:03 2013 +0000 @@ -0,0 +1,88 @@ + +#include "mbed.h" +Serial pc(USBTX, USBRX); +Serial device(p28, p27); +DigitalOut m11(p21); +DigitalOut m12(p22); +DigitalOut relay_stepper(p23); +DigitalOut stepper1(p24); +DigitalOut stepper2(p23); +DigitalOut laser(p25); +int frame1,frame2,frame3,temp; + +int main() {laser=0; + char temp=NULL; + stepper1=0; + stepper2=0; + + device.baud(2400); + + while (1) { + + //RF Receive Code + if (device.readable()) { + temp=device.getc(); + + frame1=temp%4; + temp=temp/4; + frame2=temp%4; + + frame3=temp/4; + //pc.printf("\n\r%d %d %d %d %d",temp,frame1,frame2,frame3,x); + + switch(frame1) + { + case 0: //left + m11=0; // right motor on(p21) + m12=1; // left motor off(p22) + break; + + case 1: // straight + m11=0; // right motor on(p21) + m12=0; // left motor on(p22) + break; + + case 2: // right + m11=1; // right motor off(p21) + m12=0; // left motor on(p22) + break; + } + switch(frame2) + { + case 0: //left + relay_stepper=!relay_stepper + break; + case 1: // right + break; + case 2: + stepper1=!stepper1; + stepper2=!stepper2; + break; + + } + switch(frame3) + { + case 0: //left + m11=1; + m12=1; + laser=0; + break; + + case 1: // right + m11=1; + m12=1; + laser=1; + break; + + case 2: + laser=0; + break; + + case 3: + laser=1; + break; + } + } + pc.printf("\n\n\r%d %d %d",frame1,frame2,frame3); + } +} \ No newline at end of file