Report
4 years, 7 months ago.

urgent help xbee mbed coding

i m sorry guys i m repeating the questions but i need urgent help Code for the TX

#include "mbed.h"
Serial pc(USBTX, USBRX);
Serial xbee1(p13,p14);
DigitalOut rst1(p8); //Digital reset for the XBee, 200ns for reset
DigitalOut myled(LED3);//Create variable for Led 3 on the mbed
 int main() { 
 
    rst1 = 0; 
    myled = 0;
    wait_ms(1)
    rst1 = 1
    wait_ms(1);
    while (1) {//Neverending Loop
     myled = 1; //Turn Led 3 Off
    int Y=8;
    xbee1.printf("%d", Y); //XBee write whatever the PC is sending
    wait(1);
    myled = 0; //Turn Led 3 on for succcessfull communication
    wait(1);
        }
    }
 <</code>>







Code for the RX
<<code>>
 #include "mbed.h"
 Serial xbee1(p9, p10);
 Serial pc(USBTX, USBRX);
 DigitalOut rst1(p8);
 
 DigitalOut myled1(LED1);
 DigitalOut myled4(LED4);
 int main() {

     rst1 = 0;   //Set reset pin to 0
     myled1 = 0;
     myled4=0;
     wait_ms(1);
     rst1 = 1;   //Set reset pin to 1
     wait_ms(1);
     int X; 

     while (1) {
        if(xbee1.readable()){
             wait(1);
              myled1 = 1;
             
            xbee1.scanf("%d", &X);
           // X = xbee1.getc();
             wait(1);
             myled1 = 0;    
             if(X==10)  {
            pc.printf(" correct data rcv");  
             myled4=1;  
               
             }    
             else
             pc.printf(" incorrect data rcv");  
             
           }
         }
     }


above two are two codes. the problem statement is i have to transmit something from (xbee+mbed) and rcv the same from the other (xbee+mbed).. and if it rcvs the same which is being transmitted a led should glow in the rx side mbed... to check the output i have only XCTU terminal

i m not able to get the desired output... can anybody help me in correcting the program guys plz help plz plz

Comment on this question

1 Answer

4 years, 6 months ago.

.


To post an answer, please log in.