8 years, 3 months ago.

how to make this receive code to send code?

this right now is the relay receive from the xbee. but i want the relay to send to the xbee. how to change it?

const char RelayCommand[3] = { 0xAB, 0x01, 0x99 };

if (xbee1.readable()) {
            byteIn = xbee1.getc(); 
       if (byteCount < 3) { // still looking for the header
         
         if (byteIn == RelayCommand[byteCount]) 
           byteCount++;                                           
         
         else if (byteIn == RelayCommand[0])        
           byteCount = 1;                                         
         
         else 
           byteCount = 0;                                        
       } 
       else {   // got the full header.
        
           if (byteIn == 0x01) {
             Relay = 1;
             pc.printf("on");
           }
           
           else if  (byteIn == 0x00) {
             Relay = 0;
             pc.printf("off");
           }
           byteCount = 0; 
       }                   
     }
   }
}
Be the first to answer this question.