const int relayPin =6; // attach to "s" of relay module char input = 'U'; // set input to Unassigned void setup() { pinMode(relayPin, OUTPUT); //initialize relay as an output Serial.begin(9600); // initialize serial connection } void loop() { if(Serial.available()){ // check for connection input = Serial.read(); // take the input value if(input == 'P'){ digitalWrite(relayPin, HIGH); // turn the relay to HIGH if inpit = P } else{ digitalWrite(relayPin, LOW); // otherwise turn the relay off } } delay(1000); //wait for 1 second }