Arduino Light Sensor Tutorial: Learn to Setup a Photoresistor

preview_player
Показать описание
In this video I go through the steps on how to setup an Arduino light sensor circuit and the code to make it come alive. This electronics part is extremely handy if you need to make a project that needs to be able to detect changes in light.

The parts that you will need are basic and come in most electronics starter kits so you’re likely to already have them. If not, you can pick up all the parts for pretty cheap with the exception of the Arduino Uno.

The circuit is incredibly simple so you shouldn’t have many issues putting it together. If you do find it a little hard to follow, then be sure to check out the full circuit diagram over at the website linked above. It shows you exactly where parts can be placed and the correct connections.

If you have never heard of a photoresistor it is small part that changes its resistance depending on how much light is on it. For example, if it is dark then the part will have a very high resistance, typically up to about 10 megohms. In the light it has a very low resistance of only just a few hundred ohms.

The code is very easy to follow and much like the circuit shouldn’t be too hard to get working. We simply get the value from the light sensor input and then compare it to a static value. It is likely you will need to update these static values depending on the environment you will have your setup in. For example, inside or outside.

If you’re having trouble setting it up correctly be sure to take a look at setting up some debugging and monitoring the code using the serial monitor. This should be able to help you pinpoint the problem you’re likely having.

Рекомендации по теме
Комментарии
Автор

Thanks, it worked for me. I used standard light sensor with 1K ohm resistor and 220 ohms resistors with LEDs.

AlexeyLopushanskiy
Автор

Nice video. Please add schematic diagram so beginners like me can easily follow. Thank you. 👍🏼

ms.jeremypacillos
Автор

Very helpful, thanks a lot gentlemen, and upload more about electronic.

zeeshanhaider
Автор

nigga u just arduinoed my heckin life up

HaraldNilsson
Автор

i am planning on using a light sensor with some pir motion sensors so they light up the stairs when someone walks in when it's dark. i am also thinking on making the light led strips on every step and it lights up with cool motion, like it when someone comes from downstairs it lights up from down to the top or if the someone comes from the top it lights from the top to the bottom.

lukmanalghdamsi
Автор

Connection with a laptop/PC is necessary only while coding right?
I want to use light sensors outside, far from any connectivity, to measure direct sunlight (lux>32, 000)
Is it possible to set up the light sensor system with a battery for power and a memory device to store lux data?
Also, once maximum luminosity is exceeded, will I keep receiving the maximum measurement or will it crash or something?
Thank you.

Nuskeros
Автор

Could u give a solution for the deadly shooting in sandy hook, stoneman Douglas high school, etc using arduino?

bronsonsihole
Автор

Great video. Could you please not use music with the video or maybe turn the music down lower. subbing

charlese
Автор

Hello!
can you tell me why we use Analog value "50"??

fuuastinnovatia
Автор

So I recently bought a tiny Christmas tree for my room that came pre lit and wanted to add a light sensor to it. How would I go about this? The lights simply plug into an outlet in the wall and turn on I was thinking maybe adding an arduino somewhere in the mix I just don’t know exactly where to begin and what the code would look like?

Ky_
Автор

Creative video, thanks for sharing :)

RixtronixLAB
Автор

why in your program you wrote:
if (analogValue <50)
redLed will be HIGH?
You said that when the resistant is low that mean it's has more light and not dark, so that means that theGreen led should be HIGH instead.
It's seems to me that you did the oposite to what you say about light means low resistance and darl high resistance.
Hope to hear your explanation about this, thanks!

amitayamar
Автор

Schematic would be easier...Good Video...

weerobot
Автор

This video would be so much better if you included diagrams, besides, great work.

emceha
Автор

Is there any project which can sense both motion and light

basavarajtamanagoudru
Автор

if i wanted to code two of these light sensors on one board how could i duplicate this code

samuelmunzer
Автор

Hey, I'm just confused about one thing. Why are we adding a resistor in series with the photoresistor? What's the purpose of this?

johnjohn
Автор

Wait, why not make a common cathode connection for 3 LEDs and put a single resistor between cathode node and gnd? That simplifies the circuit and you need just a single resistor for LEDs.

ShomiTheGreat
Автор

in the part where it says else{ it tells me to add "if" at the start

nqtiolandz
Автор

got 'greenLedPin was not declared in this scope'?

NtTROxUMP