Placeholder Image

字幕表 動画を再生する

  • please go to the line the computer guy dot com In order to view schematics, code and Maur for the projects that you are learning about welcome back.

  • So in this video, I'm going to show you how to use a photo, a resistor with an Arduino.

  • So a photo resister is an analog sensor that reads the value of a light in an environment.

  • So this doesn't simply tell you whether the lights are on or whether the lights are off, But it actually tells you how bright the lights are on a particular environment.

  • So this might be useful if you're doing some kind of art we know project where you're trying to grow plants.

  • So let's hear using a soil moisture sensor, you're doing a couple of other things.

  • You're trying to figure out why some plants grow better than others.

  • Well, one of the reasons, maybe, is that maybe some plans get Maur sunlight than other plants, so you can use a photo resistor to be able to find out what the value of light in an environment is, and then be able to log that into a database or were into a file or something like that so that you can go back and then analyze the information.

  • And what you might find out is, oh, these plants over here, they actually get more light than the plants over here.

  • And therefore that's what's going on.

  • So basically, all a photo resistor does is it allows you to see how much light there is an environment on.

  • Then you're able to turn that into a value for variable and do with that as you will so that let's go over to the work bench so I can show you how to build this particular project.

  • Then I will show you the code and we'll bring it all together and show you how it works.

  • So here is our project already assembled.

  • There's really not a whole lot to this project, but there are a couple of things.

  • There are a couple of things that are kind of a ga ches with this project just to keep in mind when you're going, be assembling it.

  • So we're gonna be using our way.

  • No, no, no board like we do for many of our projects.

  • The important thing is you're gonna be using a different aren't we?

  • know board is simply that you need analog inputs, which basically any any board should be ever give you.

  • So where this one We're gonna be using a five analog five and this is going to be giving us the value from the photo resistor sensor here.

  • Right then passed that What we have is we have the power wires.

  • So we have vcc the power going in and the power going in to this photo resister is we're having at five volts.

  • Now it is important.

  • Understand that I did play around with this and you can use 3.3 volts and out order to power the censor.

  • The only difference is it.

  • Since it's an analog sensor, you will get a different value readings if you only give it 3.3 volts.

  • So that's just something to realize is you can give it three before or you can give it five volts.

  • But if you're going to do things like if Elle's statements the important thing to realize is that if you're using 3.3 volts, the number that you're going to get is much smaller, so just decide whether you're going to use five or three and always use that.

  • Then we're gonna go over here and we're going to see how this thing is built.

  • And again it's a little a little wonky compared Thio House on the electronic projects we create our So the first thing is we have our vcc We have our five old and that is going into the positive pen on this photo resistor sensor.

  • So that comes in here then the next thing that we have going on, which is kind of weird, is we have a resistor.

  • So I am using a 220 home resistor here.

  • And so we're going to put that in line with the ground for the photo resistor and then in the exact same line as the ground for the photo resister.

  • We are going to put the sensor output so you have the ground for the photo resister.

  • You have one prongs of the resistor and then you have the censor all in a line and then the sensor goes over your fear a five, then what you have is you have the resistor and the resistor, then comes over and actually connects to the normal ground.

  • This is kind of a wonky thing.

  • We haven't seen this a lot in a lot of projects, but basically, when you're having the photo resister is so the sensor wire is off of the ground off of the photo resistor.

  • But you're also using a resistor here.

  • We're using the 220 ohm resistor, and they were connecting that to Brown on the board.

  • And that's what brings us all together.

  • Now, if you go and look at other people's projects, you may notice that they say to use different resistors.

  • So when I was doing some research on this, a lot of people said to use 4.7 k resistors.

  • Some of the people said to use 10 K resistors and from what I found is the tolerance for this photo resister.

  • You're not going to burn it out.

  • If you use only something like a 2 20 ohm resistor, you're just going to get different values, right?

  • So if I use a if I use a 4.7 k resistor with the values that I get out of, this will be in the hundreds, right?

  • So it'll be like 800 or 300 or 445.

  • Whereas if I use a 220 home resistor, the values I get out of it are 80 and 90 and 30 and 60.

  • So I really haven't found any problems using a 220 over sister.

  • It doesn't burn out.

  • It doesn't cause any problems with photo resistor itself, The main difference is again you just simply get different numbers.

  • So again, if you're doing if l statements, if you're using a 4.7 k resistor and you're using if l statements, then you're gonna have to realize your numbers are going to be in the hundreds.

  • Whereas if you use a 220 ohm resistor, then you have to realize your values are going to be in the tents.

  • So the 40 50 30 60 or whatever else.

  • So the main thing with us, the main thing with this since this is an analog sensor, is the output is all based on the electricity going in and the resistance.

  • So the more resistance you have, the more or less electricity you have, the different values you're going to get.

  • So if you're going to be creating If l statements.

  • You just have to remember that those F l statements have to correspond to whatever bolted you're putting in whatever resisters were putting it.

  • So with this particular project, I'm using five volts and I'm using a 2 20 resister.

  • You can use a 4.7 K a resistor, and you can use the 3.3 volts.

  • But your readings are simply going to be different.

  • So that's one of the things just to keep in mind here.

  • So with that, let's go over and take a look at the code.

  • So here's the code for this particular project.

  • So it is important, Understand?

  • With this project, all we're going to be doing is reading and the value and that this photo resister is providing.

  • So that is going to be printed out to the serial monitor, and that is it.

  • Code is so simple.

  • The first thing that we need to do is we need to define the light sensor pen so pound define.

  • We're going to call it light sensor, and that is going to be connected to analog port five.

  • So a five to be a 01234 or a five then we're going to dio go down and we're going to set up the environment.

  • It's avoid set up, and all we're going to do is cereal up again.

  • 9600.

  • So we're going to be starting the serial monitor then passed that we're going to do is write go into the loop.

  • So the loop we're going to create an insecure for a light level.

  • So basically, this is the variable that we're going to be reading, and now we have to set a value for that variable and to set the value for that, like level variable, we're going to do the analog reader function.

  • So analog read reads the analog signal from the light sensors of a school or saying is reading the value coming in from a five and a sign that value to the variable light level.

  • Then all we're going to do is cereal about print, line the value for life level and then delay for 1000 milliseconds or one second, and blue, blue, blue, blue, blue.

  • So this is going to dynamically show us the amount of light that this photo resistor.

  • It seemed at the particular point in time.

  • So with that.

  • Let's let's upload this code and I can show you how this works.

  • Okay, so I uploaded the code we have are, we know, plugged into our computer so we can read the serial monitor and also power the art away now.

  • And here we have our little photo resistors.

  • What we're gonna do is write the tools were going open, serial monitor, and then we're going to see at the value at the photo Resister is seen, so you can see this is a very well lit environment.

  • So this is in my studio.

  • I have a lot of lights pointed at me, and I'm getting undervalue somewhere between 92 95.

  • Now it is important with these analog sensors.

  • The number is you get to be a bit flaky.

  • A lot of times you get a range of numbers.

  • It's not simply that you get 95.

  • Just constantly get that a lot of times with the fluctuations with electricity, your fluctuations with a sensor, you will get a range.

  • And so with this, even though the light isn't changing and all, we get a range of about five you know, anywhere between 89 to about 95.

  • And so this is just something to keep in mind where, whenever you're using the values of analog sensors for variables for if l statements you, you don't want to be too precise with right, so we can see this is 90 or 89.

  • So I may want to trigger something to happen at 70 or 60.

  • I probably wouldn't wouldn't want something to happen between 88 89 if that makes any kind of sense so that we can see you like to say it's getting over between 89 about 95.

  • Never come over.

  • And I put my hand over the sensor.

  • We can see now the light level has dropped.

  • And now, now again, we're seeing, like 53 54 we're still getting that fluctuation.

  • Now if I reach underneath the table and actually turn out the lights to my studio so we can see it's pretty dark right now, Then we can see the number goes down, you know, somewhere between 13 to 16.

  • So it is important to understand that over there I actually still have some lights on in the rest of my basement.

  • And so this is still able to read those lights.

  • So at a dark level like this, we're still getting that number.

  • I completely put my hand over it.

  • Then we can see we go all the way down to zero.

  • But the important thing to see is that you really do get a wide, wide range of values here, depending on how much light the sensor is actually reading.

  • And so that's really all there is to this photo resistor sensor and how you're able to read the value that it's able to provide you.

  • So that's all there is to using an analog a photo resistor sensor on an Arduino, so you're able to take the number again.

  • Since it's an along, you get a nice range in there anywhere from zero to about 100 for what I'm dealing with here and then, depending on what's going on, you can either trigger alerts toe happen or that trigger of lights to turn on or log long events, that type of thing.

  • So if you're thinking about like why you might use a sensor like this, this may be valuable again.

  • If you have something like a little herb garden Let's say you have an herb garden.

  • You're trying to figure out why it's not growing as well as it should.

  • You put one of those that little Lord we know projects there again with the soil moisture sensor, maybe a temperature sensor, and you can have a nice little environmental sensor suite.

  • Try to determine why your plants may not be growing the way that you would want them to grow, or one of the things to be thinking about again when important things with our very noses.

  • The idea of being able to trigger physical offense based off of sensor readings is in a lot of office environments.

  • Now one of the good things with office environments is there that they're trying to provide more natural lights.

  • We have more skylights, and we have more windows, right, so we have more light coming in from the natural world.

  • That's good for health.

  • That's good for energy efficiency.

  • That's great for a lot of things.

  • One of the problems you may run into, though, is what happens if it's cloudy, or what happens if a storm comes in right, So a lot of times people's productivity goes down, based off of the light level.

  • So have a lot of light is provided in your office environment by the natural light situation.

  • If the outside gets dark, for some reason, having a sensor like this be able to trigger internal lengths to turn on might be a valuable thing again.

  • Instead of simply having people manually turn lights on or may noy turn lights off, you know you could have a sensor, and this sensor says Okay.

  • If the light in the environment is over 80 then turn the lights off and then the clouds go overhead.

  • And so it goes.

  • Okay, if it's if it's under 70 between, let's say, 60 Yosemite, turn these particular lights on and then we turn those lines and then if it gets darker than go over, if it's between 40 to 50 then turn these lights on and these lights on right so you can create an automatic system to turn the lights on and off based off of what's going on in the outside world.

  • So that's how little sensors like this could be valuable.

  • And it's one of those things to be thinking about.

  • It's like, Okay, what what conditions in the world is lighting important.

  • Forget lighting is important for plants.

  • Lighting is important for office space work environments.

  • What other places is lighting important for?

  • And then think about how you could use one of these sensors in order to trigger physical events to make things better for your clients and customers.

  • So with that as always, I am you.

  • Are we doing this video?

  • Then look forward to seeing the next one.

please go to the line the computer guy dot com In order to view schematics, code and Maur for the projects that you are learning about welcome back.

字幕と単語

ワンタップで英和辞典検索 単語をクリックすると、意味が表示されます

B1 中級

Arduinoを使ったフォトレジスター光センサー (Photoresistor Light Sensor with Arduino)

  • 6 0
    林宜悉 に公開 2021 年 01 月 14 日
動画の中の単語