Create a gist now

Instantly share code, notes, and snippets.

Wireless Controlled Relay
int pin = 8;
void setup(){
Serial.begin(9600);
pinMode(pin,OUTPUT);
digitalWrite(pin,LOW);
}
void loop()
{
if (Serial.available()) {
delay(100);
while (Serial.available() > 0) {
if((Serial.read())=='1')
{
if(digitalRead(pin)==LOW)
{
digitalWrite(pin,HIGH);
Serial.println("RELAY ON!");
}
else
{
digitalWrite(pin,LOW);
Serial.println("RELAY OFF!");
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment