7 years, 7 months ago.

am i doing this correct?

sending the relay on/off to another device

DigitalOut Relay(PB_0);
Serial xbee1(PB_6, PB_7);
bool relayon = false;

const char RelayCommand[3] = { 0xAB, 0x01, 0x99 };
void sendRelay(bool on)
{for (int i = 0; i<3; i++)
        xbee1.putc(RelayCommand[i]);
    //send the relay status
    if (on)
        xbee1.putc(0x01);
    else
        xbee1.putc(0x00);

    // set/clear the flag indicating that the relay is in.
    relayon = on;}
Be the first to answer this question.