Arduino Mega use Serial 1 to control device

Hi,
I put delay back on.

void loop() {
byte lighton[] = {0b1100, 0b1100, 0000, 0001};
Serial1.write(lighton, sizeof(lighton));
delay(10000);
}

Now
If it is off, then it will not go on.
If it is on, then it will turn off.

Wen

Maybe the "CC01" sent from your tester is just two bytes.

Try changing your array to have just this ...

0xCC, 0x01

Hi Hackscribble,

Thank you for not giving up on me. :slight_smile:

void loop() {
byte lighton[] = {0xCC, 0x02};
Serial1.write(lighton, sizeof(lighton));
delay(5000);
}

I tried but still not working.

Wen :frowning:

byte lighton[] = {0xCC, 0x01};

not working

Just to confirm a couple of things ...

In your original post, this code turned the light OFF (if it was on) but would not turn it ON. Is that right?

void loop() {
    byte lightonoff[] = {1100, 1100, 0000, 0001};
    Serial1.write(lightonoff, sizeof(lightonoff));
    delay(10000);
}

In a later post, the new code below turned the light ON (if it was off) but would not turn it OFF?

void loop() {
  // read from port 1, send to port 0:
    byte lighton[] = {0b1100, 0b1100, 0000, 0001};
    OR
    byte lighton[] = {0xC, 0xC, 0x0, 0x01};
    Serial1.write(lighton, sizeof(lighton));
    delay(10000);
}

And the latest code, sending just two bytes, does that do anything to the lamp?

Thanks

Ray

Do you have a link to any information about the device? I'm wondering if there is documentation on the commands it accepts.