Control AC Light Using Relay With Arduino Mega 2560


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

Similar Articles