int relaypin = 13; // relay is connected to pin 5 int phonepin = 8; // phone output is on 13 boolean relayon = false; // set up the variable. void setup() { pinMode(relaypin, OUTPUT); // The relay pin is a output from the arduino. pinMode(phonepin, INPUT); // The phone pin is a input to the arduino. digitalWrite(phonepin, LOW); // when project is turned on, relay must start off. } void loop() { if (digitalRead(phonepin)) // when the phone pin is high, when voltage is present, when the phone rings. { relayon = !relayon; // change the state of the variable. delay(1000); // Delay 1 second digitalWrite(relaypin, relayon); // Change the state of the output pin depending on the variable delay(5000); // Delay 5 seconds } }