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

  • @user-ed3se9bt9v
    @user-ed3se9bt9v3 ай бұрын

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

  • @zeeshanhaider9741
    @zeeshanhaider97413 жыл бұрын

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

  • @lukmanalghdamsi3189
    @lukmanalghdamsi3189 Жыл бұрын

    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.

  • @Ky13_
    @Ky13_6 жыл бұрын

    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?

  • @ms.jeremypacillos7993
    @ms.jeremypacillos79933 жыл бұрын

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

  • @fuuastinnovatia2058
    @fuuastinnovatia20587 жыл бұрын

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

  • @basavarajtamanagoudru579
    @basavarajtamanagoudru5796 жыл бұрын

    Is there any project which can sense both motion and light

  • @samuelmunzer8950
    @samuelmunzer89506 жыл бұрын

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

  • @Paulzmusic
    @Paulzmusic8 жыл бұрын

    Keep making Videos!

  • @Bianchi77
    @Bianchi772 жыл бұрын

    Creative video, thanks for sharing :)

  • @melonate8781
    @melonate87817 жыл бұрын

    Thanks works great

  • @bronsonsihole2882
    @bronsonsihole28824 жыл бұрын

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

  • @CrazyCoupleDIY
    @CrazyCoupleDIY7 жыл бұрын

    Thanks a lot

  • @N1tTROxUMP45
    @N1tTROxUMP455 жыл бұрын

    got 'greenLedPin was not declared in this scope'?

  • @alexgomez-xx8pl
    @alexgomez-xx8pl3 жыл бұрын

    Thank you mate

  • @oldguy8177able
    @oldguy8177able4 жыл бұрын

    good job mate

  • @HaraldNilsson
    @HaraldNilsson6 жыл бұрын

    nigga u just arduinoed my heckin life up

  • @nqtiolandz8293
    @nqtiolandz82933 жыл бұрын

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

  • @Nuskeros
    @Nuskeros2 жыл бұрын

    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

    @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

  • @amitayamar
    @amitayamar7 жыл бұрын

    why in your program you wrote: if (analogValue

  • @deepshulpradeep2549

    @deepshulpradeep2549

    7 жыл бұрын

    Would a 270E resistor work properly for the photo resistor אמיתי עמר

  • @lorenalima3833
    @lorenalima38336 жыл бұрын

    which logic gates can i use in this circuit?

  • @adrianpineda2955
    @adrianpineda2955 Жыл бұрын

    Thankyou.

  • @charlese40187
    @charlese401877 жыл бұрын

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

  • @sushipackdushi1

    @sushipackdushi1

    Жыл бұрын

    agreed haha

  • @ShomiTheGreat
    @ShomiTheGreat7 жыл бұрын

    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

    @caseylocke4474

    5 жыл бұрын

    As long as only one LED is on at a time, my (very limited) understanding is this would work just fine.

  • @weerobot
    @weerobot5 жыл бұрын

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

  • @johnjohn7379
    @johnjohn73798 жыл бұрын

    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

    @fernandomolinamenor1840

    8 жыл бұрын

    The aim is to limit the current flowing through the photoresistor in order to avoid an overload.

  • @zvezdan__

    @zvezdan__

    7 жыл бұрын

    It is not in series, it goes to the ground wire. It's a voltage divider.

  • @obtron

    @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)

  • @emceha
    @emceha5 жыл бұрын

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

  • @johnmummert8164
    @johnmummert81647 жыл бұрын

    Looking forward to view your project of opening a chicken door in the morning using a photocell and motor

  • @thescreamthescream
    @thescreamthescream6 жыл бұрын

    but the circuit will function just properly without declaring all of those variables ,we only need one to read the signal from the sensor, :)

  • @electronicsolutionindia3538
    @electronicsolutionindia35385 жыл бұрын

    nice

  • @ThatOneRobloxDev
    @ThatOneRobloxDev2 жыл бұрын

    i think i blew the photoresistor, i used it with a 100 ohm resistor, so yeah, i blew it, it stays on red forever :(

  • @shreyathakur1942
    @shreyathakur19426 жыл бұрын

    Can someone help me with this ?

  • @janmartinsky9101

    @janmartinsky9101

    6 жыл бұрын

    Yes, just tell me your problem.

  • @Krazy0

    @Krazy0

    3 жыл бұрын

    Yes, tell us the problem

  • @adrianpineda2955
    @adrianpineda2955 Жыл бұрын

    only 2 leds :

  • @caribbeanchild
    @caribbeanchild4 жыл бұрын

    voice boy!

  • @incubatork
    @incubatork6 жыл бұрын

    Can you try slowing down your naration and take a breath now and again, would sound a bit more human rather than robotic

  • @beanapprentice1687

    @beanapprentice1687

    4 жыл бұрын

    slow the speed of your video if you can't understand him

  • @jamesspaulding7580
    @jamesspaulding75803 жыл бұрын

    Didn't work for me... I'm a beginner anyways, so I'm sure I'll get better!

  • @caseylocke4474
    @caseylocke44745 жыл бұрын

    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

    @hedikacem7674

    5 жыл бұрын

    the resistor is to extend result width of the photoresistor in arduino

  • @obtron

    @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.

  • @vasanthvsj51
    @vasanthvsj516 жыл бұрын

    chiii

  • @Zackckk
    @Zackckk7 жыл бұрын

    smell

  • @daviddavidsonn3578
    @daviddavidsonn35786 жыл бұрын

    can someone translate this to English please?

  • @caseylocke4474

    @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. ;)

Келесі