Arduino Light Sensor Tutorial: Learn to Setup a Photoresistor
Ғылым және технология
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.
Full Tutorial: arduinomylifeup.com/arduino-l...
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.
I hope that you have been able to set up this Arduino light sensor without too many problems. If you have an issue, I have got something wrong, have feedback or anything else then please feel free to leave a comment below or over at arduinomylifeup.com
Пікірлер: 56
Thanks, it worked for me. I used standard light sensor with 1K ohm resistor and 220 ohms resistors with LEDs.
Very helpful, thanks a lot gentlemen, and upload more about electronic.
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.
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?
Nice video. Please add schematic diagram so beginners like me can easily follow. Thank you. 👍🏼
Hello! can you tell me why we use Analog value "50"??
Is there any project which can sense both motion and light
if i wanted to code two of these light sensors on one board how could i duplicate this code
Keep making Videos!
Creative video, thanks for sharing :)
Thanks works great
Could u give a solution for the deadly shooting in sandy hook, stoneman Douglas high school, etc using arduino?
Thanks a lot
got 'greenLedPin was not declared in this scope'?
Thank you mate
good job mate
nigga u just arduinoed my heckin life up
in the part where it says else{ it tells me to add "if" at the start
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.
@Therandomguyshorts
5 ай бұрын
Yes they give u a batter that has 3 Aa batteries roque Dd and two wires red and black so with that battery they give u a big battery thing which has 2 pins on top and u can connect that to get power or if h don’t have that battery use the big battery thing with that 3 Aa Bettie’s inside connect the red wire into the left and black to right if that doesn’t work try switching g the wires black right and red left and connect that round port to the port on aurdino And it shall work u don’t need a memory card it already knows but don’t press the reset button and if h do u have to redo the code again NOTE: aurdino isn’t water proof so if it’s raining u might want to clean it up fast cuz if water goes in the ports pin holes it will not work
why in your program you wrote: if (analogValue
@deepshulpradeep2549
7 жыл бұрын
Would a 270E resistor work properly for the photo resistor אמיתי עמר
which logic gates can i use in this circuit?
Thankyou.
Great video. Could you please not use music with the video or maybe turn the music down lower. subbing
@sushipackdushi1
Жыл бұрын
agreed haha
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.
@caseylocke4474
5 жыл бұрын
As long as only one LED is on at a time, my (very limited) understanding is this would work just fine.
Schematic would be easier...Good Video...
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?
@fernandomolinamenor1840
8 жыл бұрын
The aim is to limit the current flowing through the photoresistor in order to avoid an overload.
@zvezdan__
7 жыл бұрын
It is not in series, it goes to the ground wire. It's a voltage divider.
@obtron
5 жыл бұрын
we are taking the voltage across the resistor connected to the ground, now this voltage is dependent on the resistance of the photoresistor by V = (Vin*R)/(R+PR)
This video would be so much better if you included diagrams, besides, great work.
Looking forward to view your project of opening a chicken door in the morning using a photocell and motor
but the circuit will function just properly without declaring all of those variables ,we only need one to read the signal from the sensor, :)
nice
i think i blew the photoresistor, i used it with a 100 ohm resistor, so yeah, i blew it, it stays on red forever :(
Can someone help me with this ?
@janmartinsky9101
6 жыл бұрын
Yes, just tell me your problem.
@Krazy0
3 жыл бұрын
Yes, tell us the problem
only 2 leds :
voice boy!
Can you try slowing down your naration and take a breath now and again, would sound a bit more human rather than robotic
@beanapprentice1687
4 жыл бұрын
slow the speed of your video if you can't understand him
Didn't work for me... I'm a beginner anyways, so I'm sure I'll get better!
1:44 - I do not understand the purpose of the 220 ohm resistor. I thought the photoresistor was acting as the resistor here? All I know is that's called a voltage divider and I cannot find ANYONE who can explain it where this beginner can understand it. Why can't you just push the 5V through one side of the photoresistor and measure the analog voltage coming out the other side of the resistor? 5V in will never exceed 5V out, so no damage to the ADR. I don't get it.
@hedikacem7674
5 жыл бұрын
the resistor is to extend result width of the photoresistor in arduino
@obtron
5 жыл бұрын
we are measuring the voltage across the 220 ohm resistor rather than the photoresistor because if we use the photoresistor alone then despite the resistance (which varies with light) the voltage measured across the photoresistor will be 5v (only current varies) , so we build a voltage divider and Vout=(Vin * R)/(R+P) now as P varies vout varies and we get analog values, by connecting a POT instead of 220ohm we can vary the sensitivity.
chiii
smell
can someone translate this to English please?
@caseylocke4474
5 жыл бұрын
What is that supposed to mean? What language are you speaking right now? Pretty sure it's the same as he's speaking. ;)