int relaypin=2;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(relaypin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
while(Serial.available()==0){
}
char cmd=Serial.read();
if(cmd=='1'){
digitalWrite(relaypin, HIGH);
}
else if(cmd=='0'){
digitalWrite(relaypin,LOW);
}
delay(10); // this speeds up the simulation
}