Control AC Light Using Relay With Arduino Mega 2560

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

Up Next
    Ebook Download
    View all
    Learn
    View all