Home Arduino Projects Arduino Light Sensor Project

Arduino Light Sensor Project

by Nikodem Bartnik

One of the most common smart home systems is the one that turns on the light when it is dark. Many cars nowadays have such lights. they simply turn on automatically when it is dark.

Everybody can see the usefulness of such devices without thinking a lot, and the good news is that it is very easy to build something of this sort using the Arduino Uno board.

All you need is the Arduino Uno board and few basic components. You can also add a relay to it to control high devices if needed.

Light sensor with the Arduino Uno board

Here is what we need to build our system:

Arduino Light Sensor Project

This Arduino project will also be interesting if you use the whole settings to control a Lamp as we did in the Arduino relay project.

Remeber the color of the LED doesn’t matter in this project. Make sure you have properly connected a resistor with the photoresistor; this is important and help create a voltage divider to get it working. For the LED I used a 300Ω resistor and for the photoresistor a 2,4kΩ resistor.

Arduino Light Sensor Project
Arduino Light Sensor Project
Arduino Light Sensor Project
Arduino Light Sensor Project
Arduino Light Sensor Project

When the connections are ready, we can upload the code to the Arduino. What the code does is: it reads the value from the analog pin A0. If the value is smaller than 650, it turns the LED ON (it basically turn the LED on when it is dark). if the value is bigger than 650, it will turn OFF the LED.

As an addition, it will print the analog value on the serial so you can see it and eventually adjust the resistor values or threshold for the control the LED.

Here is the code:

Feel free to play with the code and do not forget to adjust it to your needs.

You might also like:

Related Posts

Leave a Comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Privacy & Cookies Policy