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
Connection
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); // Turns ON Relays 1
- Serial.println("Light ON");
- delay(2000); // Wait 2 seconds
- digitalWrite(RELAY1, HIGH); // Turns Relay Off
- 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".

Joe PernaPosted Nov 26, 2017, 8:25 PM
Im new to arduino, I use the mega 2560 board, what relay should I use?
Shobana JPosted Jul 8, 2016, 4:12 AM
Nice share..good one
Sr KarthigaPosted Jul 5, 2016, 10:46 AM
Thank you vignesh sir
Sr KarthigaPosted Jul 5, 2016, 10:46 AM
Thank you raja sir
Sr KarthigaPosted Jul 5, 2016, 10:46 AM
Thank you santhakumar sir
Vignesh ManiPosted Jun 9, 2016, 4:53 AM
Good one
RajaPosted Jun 9, 2016, 12:22 AM
Good one....
Santhakumar MunuswamyPosted Jun 8, 2016, 11:35 PM
Thank you for sharing
Sr KarthigaPosted Jun 8, 2016, 10:08 PM
Thank you sonu sis
Sonu ChaudharyPosted Jun 8, 2016, 2:47 PM
simple and short