Skip to content

Instantly share code, notes, and snippets.

@VincentK16
Created June 27, 2013 14:11
Show Gist options
  • Save VincentK16/5876726 to your computer and use it in GitHub Desktop.
Save VincentK16/5876726 to your computer and use it in GitHub Desktop.
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