Introduction: Arduino Light Intensity Lamp Using a Relay

After using a 24 V 15A transformer IRL to power a motor for a project that I was working on this is another way that can be used to boost the voltage in a circuit without the use of MOSFETs. With quarantine and all going on in the world the ideal way to do this is using TinkerCAD.

The general idea of this project is that whenever there is light out you don't need to have the light on but when it's dark out you would need the light to be on. I was thinking that this could be used in a backyard where you have a string of lightbulbs attached up high. You could then use this setup with the string of lights and have them automatically be lit when it gets to be a certain light level.


- An Arduino

- An LDR (Photoresistor)

- A 1K Ohm Resistor

- A 120 V Lightbulb

- An SPDT Relay

- A Power Supply (5V 5A)

- Assorted Cables

Step 1: Assembling the Breadboard

The basics of the breadboard are the relay, lightbulb and LDR sensor. The first thing that I did was hook up the LDR sensor to the Arduino's ground on one terminal and the Arduino's power to the other through the 1K Ohm Resistor. Then the power terminal has to be connected to an analog input on the Arduino so the Arduino knows the lighting condition, I used A0.

The relay looks complicated but is simple enough for what we need it to do. We first connect terminal 8 of the relay into the Arduino's ground then terminal 5 into a digital pin on the Arduino, I used pin #2. Then connect terminal 1 of the relay to the external power supply's ground, the power supply's power should be connected to one of the terminals on the light and the other terminal from the light connects to terminal 7 from the relay.

In the TinkerCAD I have my power supply set to 5V 5A.

Step 2: The Code

The code for this project is very straightforward, the first thing is to assign a variable to the pin number of the relay that controls the light, for me this is pin 2. Then in the setup function all we need to do is set that pin for output. In the loop function, we have an if-else statement that's set up to read the analog input using 'analogRead' checks if it is greater than a certain amount (I used 500) and if it is then it turns the light on or else it turns the light off. At the end of the loop function, I added a delay of 10 milliseconds to help with the TinkerCAD simulation.

This is the code I used:

int lightPin = 2;
void setup(){
  pinMode(lightPin, OUTPUT);

void loop(){
  if (analogRead(A0) > 500){
    digitalWrite(2, LOW);
    digitalWrite(2, HIGH);