Introduction
- In this article, I will explain about controlling the AC Light using relay with Arduino Mega.
- It can be used to control the light by the relay.
- The relay can act as a switch.
Parts Used
- Arduino Mega 2560
- AC Light
- Relay
- Bread Board
- HookUp Wires
Step 1 Connect the light to the Arduino Mega 2560.
- Connect the positive side to the positive side of the AC Supply
- Connect the negative side to the negative side of the AC Supply.
Step 2 Connect the relay to the Arduino Mega 2560
- Connect the vcc of the relay to the 5v of the Arduino board.
- Connect the gnd of the relay to the Gnd of the Arduino Board.
- Connect the vin of the relay to the pin 07 of the Arduino Board.
Programming
- digitalWrite(RELAY1, LOW);
-
- Serial.println("Light ON");
-
- delay(2000);
-
- digitalWrite(RELAY1, HIGH);
-
- Serial.println("Light OFF");
-
- delay(2000);
Explanation
- When the relay is ON, the AC Light is also ON.
- When the relay is OFF, the AC Light is also OFF.
- We have set the time for the delay to be ON/OFF.
- When the light is on, they will print in the serial monitor as "LIGHT ON".
- When the light is off, they will print in the serial monitor as "LIGHT OFF".