// Define the pins for Relay and Switch
#define RELAY_OUT 5
#define RELAY_IN 7
#define SWITCH_PIN 13
#define LED_PIN 8
void setup() {
// Initialize the relay pin as output and switch pin as input
Serial.begin(9600);
pinMode(RELAY_OUT, OUTPUT);
pinMode(SWITCH_PIN, INPUT_PULLUP); // Use internal pull-up resistor
pinMode(RELAY_IN, INPUT);
pinMode(LED_PIN, OUTPUT);
// Initially, turn off the relay (and the LED)
// digitalWrite(RELAY_OUT, LOW);
}
void loop() {
// Read the state of the switch
int switchState = digitalRead(SWITCH_PIN);
if (switchState == LOW) {
// Switch is pressed, activate the relay (light up the LED)
// digitalWrite(RELAY_PIN, HIGH);
Serial.println("EXHAUTS NYALA");
Serial.println("=============");
digitalWrite(LED_PIN, HIGH);
} else {
// Switch is not pressed, deactivate the relay (turn off the LED)
// digitalWrite(RELAY_PIN, LOW);
Serial.println("EXHAUTS MATI");
Serial.println("============");
digitalWrite(LED_PIN, LOW);
}
delay(500);
}