My First Arduino Project – An Automatic Night Light ⚡️

For my first Arduino project, I decided to build a simple automatic night light that turns on when it gets dark. The basic concept is to use a photocell (light sensor) to detect light levels and then turn an LED on or off accordingly.

The Components:

– Arduino Uno board
– Photocell (light dependent resistor)
– LED
– Resistors
– Breadboard and jumper wires

The Concept:

A photocell is a resistor that changes resistance based on the amount of light hitting its sensor area. In bright light, the resistance is low allowing more current to flow. In darkness, the resistance is high restricting current flow.

I used this property to build a basic light sensor circuit. By connecting the photocell to one of the Arduino’s analog input pins, we can read its varying resistance values based on light levels. With some code to set a light threshold, we can then control an LED by turning it on when dark and off when bright.

const int led = 8;
const int sensor_pin = A0;
int sensor;
const int threshold = 500;

void setup(){
pinMode(led, OUTPUT);
Serial.begin(9600);
}

void loop(){
sensor = analogRead(sensor_pin);
Serial.println(sensor);
if(sensor<threshold){
digitalWrite(led,HIGH);
} else{
digitalWrite(led,LOW);
}
}

The end result is a compact night light that automatically lights up whenever the ambient light drops below the threshold level!

Future Development:
While functional, this is a very basic project. Some improvements I’d like to make are:

  • Make it portable by integrating a battery pack for a wireless night light
  • Design it into functional household objects like lamps, book lights, stair lights, etc.
  • Program different LED brightness levels based on duration of darkness

This first project taught me the basics of working with Arduino, simple circuits, analog inputs, and lighting control. I’m excited to level up my skills on more advanced projects!

Watch it in action here! :

IMG_4512

Leave a Reply