## Introduction: SmartLight Using LDR and LCD (Tinkercad)

Hi everyone! We are students from University Tun Hussein Onn (UTHM) here to demonstrate a project that involves a LDR, LCD and Arduino using Tinkercad for our curriculum UQD0801-Robocon 1 (Group 9).

SmartLight systems are very common worldwide, from industrial areas to residential areas. It is a efficient device that can help reduce power consumption as well as aids in making sure an area is well lighted.

In this tutorial, we will show you how the system works in general as well as simulate it using Tinkercad.

## Step 1: Components Required

This project does not demand components that are too expensive or hard to acquire.

This simple project consists of;

1. Arduino Uno R3 (1)

2. Photoresistor (1)

3. LED (any color will do) (1)

4. LCD 16x2 (1)

## Step 2: How Does the Photo Resistor Work?

Photo resistors are light sensitive resistors whose resistance decreases as the intensity of light they are exposed to increases. This means that when the photo resistor is exposed to more light, the resistor decreases, making more power to flow from the output.

This is then fed into the Arduino to measure the voltage that flows inside it.

The Arduino then processes the input obtained and provide an appropriate output accordingly.

We will see more in the simulation and circuit.

## Step 3: How Do We Do the Circuit in Tinkercad?

Tinkercad is a freeware that is available online, which is a suitable tool for learners to explore the world of electronics that involve the use of sensors and Arduino.

After going through the sign up process and you end up at the circuit designer page, you can search for Arduino, which will not only bring the Arduino board, but starter boards that consists of different types of projects.

Since our project involves the use of LCD, we will firstly do a connection between the Arduino and the LCD as shown above.

## Step 4: Connecting the LDR to the Circuit

The LDR needs to be connected as such in order to function properly. The output must be between a resistor that is connected to GND as seen in the figure above. The output is connected to the analog pin of the Arduino.

This is because the output from the photo resistor is in voltage, which is not possible to be measured in the digital pins of the Arduino accurately.

In this case, we connected it to pin A0 of the Arduino

## Step 5: Connecting a LED

A LED is used in this circuit as an output as well. The LED should light up when the LDR (Photo resistor) detects that the surrounding area has gotten dimmer.

The LED is connected as shown in the figure above to the digital pin of the Arduino.

## Step 6: The Code of the Project

The code of the Project consists of two different libraries, configuring the inputs and outputs for the project and setting conditions in order to ensure the project runs as expected.

#include <LiquidCrystal.h>

LiquidCrystal lcd(12,11,5,4,3,2);

int sensorValue = 0;

int led = 7;

void setup()

{

pinMode(led,OUTPUT);

pinMode(A0,INPUT);

Serial.begin(9600);

lcd.begin(16,2);

lcd.setCursor(0,0);

lcd.print("SmartLightSystem");

}

void loop()

{

lcd.setCursor(0,0);

lcd.print("SmartLightSystem");

Serial.println(sensorValue);

delay(100);

if (sensorValue < 750)

{

lcd.setCursor(0,1);

lcd.print("LED ON");

digitalWrite(led,HIGH);

delay(100);

}

else

{

lcd.setCursor(0,1);

lcd.print("LEDOFF");

digitalWrite(led,LOW);

delay(100);

}

}