Mathias Peers
/
Receiver
xbee receiver
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 00003 Serial xbee(p9,p10); //Create serial object 00004 char a; 00005 //DigitalOut nReset(p30); //reset pin of the xbee 00006 DigitalOut myled1(LED1); 00007 DigitalOut myled2(LED2); 00008 DigitalOut myled3(LED3); 00009 DigitalOut myled4(LED4); 00010 00011 int main(){ 00012 a=255; 00013 myled2=1; 00014 xbee.baud(57600); //set the baud rate of the xbee. (9600 standard) 00015 wait(0.2); 00016 myled2=0; 00017 while(1) { 00018 if(xbee.readable()) { //Checks if the data is readable 00019 a = xbee.getc(); //Get the first character that's in the buffer 00020 if(a==0) { //detects if joystick is pressed up 00021 myled1=1; 00022 xbee.putc(255); 00023 } 00024 if(a==129) { //detects if yoystick is pressed down 00025 myled1=1; 00026 myled2=1; 00027 xbee.putc(126); 00028 } 00029 if(a==66) { //detects if yoystick is pressed down 00030 myled2=1; 00031 xbee.putc(189); 00032 } 00033 if(a==195) { //detects if yoystick is pressed down 00034 myled2=1; 00035 myled3=1; 00036 xbee.putc(60); 00037 } 00038 if(a==36) { //detects if yoystick is pressed down 00039 myled3=1; 00040 xbee.putc(219); 00041 } 00042 if(a==165) { //detects if yoystick is pressed down 00043 myled3=1; 00044 myled4=1; 00045 xbee.putc(90); 00046 } 00047 if(a==102) { //detects if yoystick is pressed down 00048 myled4=1; 00049 xbee.putc(153); 00050 } 00051 if(a==231) { //detects if yoystick is pressed down 00052 myled4=1; 00053 myled1=1; 00054 xbee.putc(24); 00055 } 00056 wait(0.2); 00057 myled1=0; 00058 myled2=0; 00059 myled3=0; 00060 myled4=0; 00061 } 00062 } 00063 }
Generated on Wed Jul 13 2022 15:24:54 by 1.7.2