// Define the pin to which the relay is connected
const int relayPin = 13; // Change this to the actual pin you have connected the relay to
// Define the pin to which the push button is connected
const int buttonPin = 2; // Change this to the actual pin you have connected the push button to
void setup() {
// Set the relay pin as an OUTPUT
pinMode(relayPin, OUTPUT);
// Set the button pin as an INPUT
pinMode(buttonPin, INPUT);
}
void loop() {
// Check if the push button is pressed
if (digitalRead(buttonPin) == HIGH) {
// If the button is pressed, turn on the motor
digitalWrite(relayPin, HIGH);
} else {
// If the button is not pressed, turn off the motor
digitalWrite(relayPin, LOW);
}
}