int RELAY1=13;
void setup()
{
Serial.begin(9600);
pinMode(RELAY1,OUTPUT);
}
void loop()
{
int val = Serial.read() - '0';
if (val == 1) { // test for command 1 then turn on LED
//Serial.println("RELAY on");
digitalWrite(RELAY1, LOW); // turn on LED
Serial.println("led off");
}
else if (val == 0) // test for command 0 then turn off LED
{
// Serial.println("RELAY OFF");
digitalWrite(RELAY1, HIGH); // turn off LED
Serial.println("led ON");
}
Serial.println("Arduino program");
delay(500);
}
I have added example code. With this code you can send 0&1 to turn On/OFF the LED