Hello guys, in this tutorial we will see how to control 240V/120V from 5V Arduino using Relay module. And we will turn on and off light by using blinking code. So, let’s get started.

Before starting this tutorial, I want to give you a warning. Since we are using 240V line voltage you should take necessary precaution when dealing with high voltage. Doing this incorrectly can cause you serious injuries. Or damage your Arduino or relay. And I am not responsible for that.

For doing this project you will need

  1. Arduino,
  2. Relay module,
  3. Diode (1N4007), for extra protection.
  4. Breadboard & Jumper Wire,
  5. 240V/120V light bulb ,
  6. Bulb holder, wire and plug.

I have putted diode between Arduino and relay. It will give Arduino extra protection by allowing current to flow only in one direction. One wire is cut between holder and plug. One end is connected to common pin (COM) and other end is connected to normally closed pin (NC). Do connection as shown in diagram.

How to control 240V/120V from 5V Arduino using Relay module

Use extension board if something could go wrong, you can switch it off directly. Now open sketch of blink. Change delay time to 2000 millisecond for on and off. Upload the sketch.

void setup() {
 // initialize digital pin LED_BUILTIN as an output.

// the loop function runs over and over again forever
void loop() {
 digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
 delay(2000); // wait for a second
 digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
 delay(2000); // wait for a second

After uploading the sketch, turn on extension board. Now we can see our 240v light is turn on for 2 second and off for 2 second.

Till then keep leaning keep making.