Making an LED Sensor Light with Arduino

This video tutorial explains how to use an Arduino Uno to make an LED light. A light sensor will detect low-light conditions to turn on an LED and also turn off an LED when light is present.

The project involves an Arduino Uno board, an LED, a light sensor which can detect different levels of light and return a value, and a breadboard with jumper wires.

The way the project works is as follows. Use the light sensor to get light readings constantly. You can specify a value which, when the light is less than this value an LED light will be turned on, and when the light is greater than this value the LED light will be turned off.

This project allows you to work with getting readings from a sensor (input), use if statements to test conditions, and use an LED to produce some form of output.

Click Tools > Serial Monitor and set to 9600 baud to view the light sensor readings received from the Arduino when it is connected via USB to the computer.

Watch the video below or click here to view it on YouTube.


The source code is also available here:

int led = 13;
int lightReading = 0;

void setup () {
  pinMode(led, OUTPUT);

void loop () {
  lightReading = analogRead(A2);
  Serial.println(lightReading, DEC);
  if (lightReading < 50) // change this value to suit light conditions. Ranges from 0 (very dark) to 1023 (very bright).
    digitalWrite(led, HIGH); // turns the light on
    Serial.println("light on");
    digitalWrite(led, LOW); // turns the light off
    Serial.println("light off");
  // Delay of 1000ms before checking light level again

Diagram and photos


The photos below show the same layout although a 470 Ohm resistor is also being used.


2 3

Light sensor readings
Light sensor readings

Leave a Reply