Introduction: Interfacing Relay With Arduino in TinkerCad

A Relay is a device that helps microcontrollers (or microcontroller based boards) like Arduino to switch on or off different household appliances like motors, lights, water heaters, television and fans etc.

Caution: We are going to connect 240V Mains supply (or 110V depending on where you live) to the 5V relay module to turn on a lamp. You should be very careful and cautious when using the mains supply. If you have even the smallest doubt about wiring it up, don’t hesitate to take help from a professional.

Step 1: Components Required:

Required Components

1.Arduino UNO (or any other Arduino board)

2.5V Relay (Either you can use single channel relay module or you can make of your own)

3.1N4007 Diode

4.BC547 – NPN Transistor

5.Red LED (can be used as a Power ON LED)

6.Resistors (1/4 W – for Red and Green LEDs)


8.Wires for connecting DC Voltage components

9.Wires for connecting AC Mains and lamp

Step 2: Single Channel Relay and Project Circuit Diagram:

Let us see the circuit diagram for the project. Even though we have used a 5V Relay Module, the connections in this circuit diagram will describe the complete setup.

It is very simple as we used a 5V relay module and not the individual components.

Most relay modules (whether 5V or 12V) will come with the aforementioned connection and hence all you need is to give power supply to the relay module i.e. 5V and GND and connect the control signal from Arduino to control pin on the relay board.
Coming to the load part i.e. the lamp, hot wire from the mains supply is connected to one terminal of the lamp. Other terminal of the lamp is connected to Normally Open (NO) contact of the 5V Relay. Finally, the neutral wire from the mains is connected to the Common (COMM) contact of the relay.

Step 3: Code:

For more interesting projects connect with me on:


Facebook page:


void setup()
pinMode(6, OUTPUT);

void loop()
  digitalWrite(6, HIGH);
  delay(1000); // Wait for 1000 millisecond(s)
  digitalWrite(6, LOW);
  delay(1000); // Wait for 1000 millisecond(s)
Arduino Contest 2020

Participated in the
Arduino Contest 2020