const int relay = 3;
const int buttonPin = 4;
void setup() {
pinMode(relay, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
Serial.begin(9600); // Initialize serial communication
Serial.println("System Ready");
}
void loop() {
if (digitalRead(buttonPin) == LOW) { // Button pressed (active LOW)
digitalWrite(relay, HIGH); // Turn on motor (relay on)
Serial.println("Motor ON");
} else {
digitalWrite(relay, LOW); // Turn off motor
Serial.println("Motor OFF");
}
delay(500); // Small delay to avoid flooding Serial Monitor
}