Skip to content

Instantly share code, notes, and snippets.

@ItKindaWorks
Created July 2, 2018 16:29
Show Gist options
  • Save ItKindaWorks/5261e07d276db34fc384f7ad12743bc5 to your computer and use it in GitHub Desktop.
Save ItKindaWorks/5261e07d276db34fc384f7ad12743bc5 to your computer and use it in GitHub Desktop.
A simple Arduino program for controlling an LC Tech serial relay board
/*
serialRelayTest.ino
*/
byte relON[] = {0xA0, 0x01, 0x01, 0xA2}; //Hex command to send to serial for open relay
byte relOFF[] = {0xA0, 0x01, 0x00, 0xA1}; //Hex command to send to serial for close relay
void setup(void){
Serial.begin(9600);
//make sure the relay is off before moving forward
Serial.write(relOFF, sizeof(relOFF));
delay(10);
Serial.write(relOFF, sizeof(relOFF));
}
void loop(void){
//turn the relay on for 3 seconds
Serial.write(relON, sizeof(relON));
delay(3000);
//turn the relay off for 3 seconds
Serial.write(relOFF, sizeof(relOFF));
delay(3000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment