Introduction: Arduino Light Intensity Lamp

Hey guys, my name is Atman and today I will be explaining to you how to make a Arduino Light Intensity Lamp.

This project is very beneficial for many engineering students. This project teaches the importance of using a relay system to control the brightness of a light bulb with a photoresistor. In this tutorial I will be showing you step by step to make this circuit. At the same time this tutorial will explain what each component does and how does it play a role within this project.

The purpose of this project is to see the light bulb light up when the brightness is low and go down when the brightness is high.

Your project at the end of this tutorial will look like the image attached.

Alright. . . Let's Go!

Step 1: Materials

1 x Arduino Uno

1 x Photoresistor(LDR)

1 x Breadboard

1 x Power Supply

10-15 Jumper Wires

1 x Relay

1 x Light Bulb

1 x 1kΩ Resistor

Step 2: Materials(Pictures)

Here are the materials with pictures.

Step 3: Wiring(Step 1)

Your first step for this project is to connect the terminal 2 of the LRD to the A0 pin of the Arduino. A0 pretty much means analog input. Analog input converts voltage into a digital value which can be stored and processed by the software.

Step 4: Connecting the LDR(pt.1)

Once this step over you must give power to the LDR. In order to do this you must add a resistor first to terminal 2 and then add power. The purpose of the resistor is to stop the flowing of current. Too much current can damage an electronic which is not good that is why we use a resistor.

As you can see from the picture that the wire connecting to ground is connected to the resistor which then will be connected to the LDR.

One information that every student must know that the wires inside the breadboard are internally connected. So if you put power into one pin of a railing the whole pin in that row has power.

Step 5: Connecting the LDR(pt.2)

Once this step is over, you must attach terminal 1 of the LDR to ground. This is an important step since you must let the electricity coming in go back to the Arduino. The only way to accomplish this is by connecting one of the railings of the LDR to ground.

Step 6: Relay

You might be wondering what is a relay. The purpose of this component is to control the circuit. There are two main switches on a relay. NC(Normally Closed) and NO(Normally Open). Later in this tutorial you will know how these two parts of the circuit plays a role. I'll explain this when we are coding the circuit.

Now we must connect the relay onto the circuit . Once this part is over, we will start wiring our circuit.

Step 7: Connecting Terminal 5

Now the relay is connected to your breadboard.

Once this is done you will connect terminal 5 of the relay to pin to pin 4. The pin 4 is not any specific pin, you can connect this to any pin you'd like, but this will be very important when it comes to the coding part.

Let us continue with this project now

Step 8: Connecting the Light Bulb

Since the relay has been connected on to the breadboard you are able to connect the light bulb to the relay and then on to the power supply.

Your first step is to get terminal 1 of the light bulb and connect it to terminal 7 of the relay. Once this is done you take terminal two of the light bulb and connect it to the positive side of the power supply. Then take the negative side of the power supply and attach it to terminal 1 of the relay.

We are almost done this tutorial!

Step 9: Wiring Power and Ground

Now since the wiring of the electronics are done you must remember that you have to give power and ground to both of the railings across the breadboard.

In order to achieve this connect one end of the ground railing to the other end of the ground railing. Once this is done, do the same thing for the power railing. This will allow the current to flow out from the Arduino and directly come back.

Before you get all excited don't forget to directly give power and ground to the breadboard. Just because you attached both of the power and ground railings together doesn't mean there is actually ground and power going through. In order to have ground and power on the breadboard you must connect the ground pin of the Arduino to the negative rail on the breadboard and the pin that says 5v on the Arduino to the positive railing of the breadboard.

Once you have completed this you are providing ground and power to the breadboard.

Step 10: Coding

To many people the word coding sounds scary, but don't worry. The code for this is very simple and I promise you, you will understand what we have written.

Let's begin.

If you look at the first line where it says const int analog = A0.

This is where the digital values coming from the Arduino will convert it into analog. Terminal two of the LDR is directly connected to A0 as you can tell from the image in the beginning of this presentation. As you read the second line you notices that the integer value is pin 4. This is where terminal 5 of the relay is directly connected to pin 4 of the Arduino. If you connected the wire to pin 5 you would have wrote pin 5 on the code.

Void Setup:

This is a important factor in your circuit. In this you will wright your INPUT and OUTPUT values. Since you are connecting A0, this would be known as a INPUT value. The photoresistor connects the current coming through from the Arduino. Pin4 from the Arduino will be a OUTPUT value since it will determine if the light bulb will turn on or off depending on the brightness of the LDR.

You might be wondering why there is a serial connection on the code. The reason is because you are establishing a serial connection between the Arduino onto the breadboard.

Void Loop:

In order to start this code we have to find a way to read and display analog that are being transmitted from the photoresistor. Therefore me must write down this code:


Once you are done, the fun begins! Just to let you know we will be using something called if statements. This statements output values depending on what conditions are being transmitted from the photoresistor.

Now you must create a code where the conditions say if the brightness is high the light bulb will not light up while if the brightness is low the light bulb will light up. In order to do this you must use a code line called analog write.

if(analogRead(A0) > 500)
{ digitalWrite(pin4, LOW); }

This code pretty much means if the value of the photoresistor is higher than 500 the light bulb will turn on.

{ digitalWrite(pin4, HIGH); }

delay(5); }

This part of the code states the opposite. This is called a else statement. If the signal is less than 500 the light bulb will not turn on.

The delay at the end of the code will delay the code from restarting by 5 seconds before restarting since you are writing this code inside of a loop.

Your final code should look like the image above.

Step 11: Conclusion

Great! You are done building your light bulb circuit. Now lets see if it works.

If you're wondering that your circuit works well look at the video attached. Your circuit should do something like this video. If it's not, look over this tutorial again. Sure you must have missed an important step.

Thanks again for taking your time and reading this tutorial !