• nithya7rns

Light Intensity Measurement using LDR sensor and Arduino on TinkerCAD

Updated: Dec 16, 2020

Light Intensity is usually measured to control the switching on and off of the light in the Home Automation system. LDR sensor is the photoresistor that plays a major role in the Light Intensity Measurement circuit.

Devices and circuits are usually designed and simulated on software before building the circuit itself. This ensures circuit safety and makes it easy to build the circuit without worrying about any hazards from the design. TinkerCad is an online simulation software for electronics circuits. Let us explore how to measure Light Intensity using LDR and Arduino.

Hardware Requirements

  1. Arduino UNO Board.

Develop a stronger concept in Arduino through this article:- What is Arduino?

Arduino UNO

#Arduino board is a microcontroller that is used to accept inputs from sensors connected and provide an output action on the desired device connected to it. The sensor inputs can be from light-detecting sensors, motion sensors (Ultrasonic or IR), temperature sensors, etc. The output from this device can be received through other output devices such as LED, Buzzer, Serial monitor, etc.

Buy Arduino UNO from here.

2. Resistors

1.5k Ohm Resistor

Resistors are passive devices that restrict the flow of current or divide the voltage through the circuit. The input power passes through these resistors and then to the sensors to avoid damage.

Buy Resistors from here.

3. Breadboard


The breadboard is the basic component of any circuit building process. All components, be it input sensors or output display devices are connected to the power supply, microcontroller using wired connections through a breadboard. The holes in the breadboard are in series. There are various sizes like full-sized, half-sized, and mini breadboard.

Buy breadboard from here.

4. LED


Light Emitting Diode is a commonly used light source. It is a semiconductor that emits light when current flows through it.

Buy LED from here.

5. Jumper Wires

Jumper Wires

These are the main components that are used to establish the connections between different devices of the circuit.

Buy Jumper Wires from here.

6. LDR (Light-Dependent Resistor)


LDR is a #photoresistor that works on the principle of #photoconductivity. The surface of the LDR is made with a layer of semiconducting material that is responsible for measuring the light intensity. The principle states that when light falls on the surface of the semiconducting material, the electrons receive energy, and movement is caused inside the material.

When those electrons reach the valence band, electron-hole pairs are formed. This in turn reduces the resistance of the material and the corresponding voltage is given as the output of the device.

Buy LDR from here.

NOTE: The description of the electrical components is given for reference. We don't need the physical components for this project. The circuit simulation is done in the TinkerCad software.

Software Requirements

TinkerCad circuit simulation software.

TinkerCad Logo

It is an online simulation software used for circuit design. It has all the electrical components required to built circuits and runs them.

Visit the TinkerCad website.

Circuit Connections

Circuit Diagram

Let us now understand the circuit connections.

First, it is necessary to define the ground and power supply line of the breadboard. This is done by connecting the 5V supply pin from the Arduino to one of the lines of the breadboard and the Ground (GND) pin of the Arduino to another line of pins of the breadboard. In the given circuit diagram, the wires in Red are connected to the power supply and those in Green are connected to the Ground.

The LDR has two terminals of which one is directly connected to the Analog pin (A0) of the Arduino and the same PIN is connected to the ground line of the breadboard through the resistor. The second pin of the #LDR is connected to the power supply line of the breadboard.

Next, in this circuit, LED is the output device. So the anode terminal of the LED is connected to the Digital pin (PIN 9) of the Arduino. The cathode terminal of the #LED is connected to the ground line of the breadboard through the resistor.

We are using Multimeter as the output indicator. Hence, the pin used for output, i.e. PIN 9 is connected to the positive (RED) terminal of the Multimeter and the negative (BLACK) terminal of the #multimeter is connected to the ground line of the breadboard.


The code for this circuit is simple to understand.

int sensorValue = 0; 

The integer "sensorValue" is declared which will be storing the value of the input from the LDR sensor. It is initialized to 0.

void setup() 
pinMode(A0, INPUT); 
pinMode(9, OUTPUT); 

The setup( ) function is used to declare the pin modes of the terminals being used. The pin A0 which is connected to the LDR is going to take input from the sensor. Hence, using the pinMode( ) function, the input mode is assigned to it. The serial transmission begins with the #Baudrate 9600.

Similarly, the output is sent to the LED which will increase its brightness according to the input from the LDR. The pin mode assigned to the PIN 9 is output. The setup( ) function ends here.

void loop() 
sensorValue = analogRead(A0); 

The loop( ) function begins by taking the input from the sensor. As we have already declared the variable to store the sensor input value, we have to take the input received by the pin/ terminal connected. analogRead( ) function is used to take value from A0 and assign it to the variable sensorValue. The same keeps printing in a loop on the Serial Monitor.

analogWrite(9, map(sensorValue,0,1023,0,255)); 

Now we have to assign the output in terms of voltage which has to be given to the LED and has to be shown on the Multimeter. The syntax of the map( ) function is as follows.

map(value, fromLow, fromHigh, toLow, toHigh) where "value" is the number to map. "fromLow" is the lower bound of the value’s current range. "fromHigh" is the upper bound of the value’s current range. "toLow" is the lower bound of the value’s target range. "toHigh" is the upper bound of the value’s target range.

A delay of 0.1 seconds is given for every output and the above statements keep executing continuously in the loop.


int sensorValue = 0; 
void setup() 
pinMode(A0, INPUT); 
pinMode(9, OUTPUT); 
void loop() 
sensorValue = analogRead(A0); 
analogWrite(9, map(sensorValue,0,1023,0,255)); 

NOTE: The default code present in the TinkerCad window needs to be removed and the program code needs to be written. Download the document and copy-paste the code in Tinkercad to simulate the circuit.

Code for Light Intensity Measurement
Download DOC • 11KB


Working of the Circuit

Let us first learn how to work on TinkerCad #simulation software. Once on the #TinkerCad page, select circuits, and search for the components required. The components are to be dragged and brought to the circuiting screen. The connection needs to be made by selecting the jumper wires. Corresponding colors for the wires can be selected.

Learn more about TinkerCad in detail.

Now let us understand how the circuit works.

When the LDR is connected, the LED is initially OFF and the Multimeter shows no reading. When the intensity of light on the surface of the LDR increases, the resistance of the semiconducting material present on the surface of the LDR decreases according to the principle of photoconductivity. This changes the voltage level also.

The voltage is given to the LED as input and based on the value transmitted, the LED glows/dims. The change in brightness of the LED indicates the light intensity. The same voltage output value is shown on the multimeter and the Serial monitor of Arduino #IDE.

Watch the below-given project video for the practical explanation of designing the circuit and to know how the simulation #software works.

Project Video By - Navya Tatiparthi

Simulation software plays a major role in the building of large circuits as they help analyze the working of the circuit before it can be built practically. It helps us create a #virtual design of the circuit we want to build and avoid damages to the circuit if in case we don't know, beforehand about the correct circuit connections.

For more projects through TinkerCad click here.

Simulation software can help us build more effective and efficient projects as it provides validation for the circuit we will be building using the actual components. #Design your own circuit, run the code in the software, and validate your project.


  • Facebook
  • YouTube
  • Instagram
  • LinkedIn
Contact Us
© Copyright - LearnElectronics 2021