Placeholder Image

字幕表 動画を再生する

  • Please go to the line.

  • The computer guy dot com and failed normal dot com to see the videos that are too dangerous for YouTube.

  • Welcome back.

  • So in this video, what we're going to dio is we're going to use a 16 by two LCD screen in order to display at the temperature in both Fahrenheit and Celsius from an analog temperature sensor.

  • What this is going to teach you how to do is this is going to teach you how to bring in data from a sensor and then be able to display both static and dynamic text on an LCD screen.

  • So what's gonna happen is the voltage is gonna be read off of this thing.

  • We're gonna turn that voltage into both of Celsius and a fair in high temperature.

  • We're then going to say temp in F and then give the value for the temperature variable.

  • They were going to do a temp and see we're going to give the value for the temperature, see variable.

  • So this allows you to be able to bring in information from a sensor and then be able to print it out on an LCD screen in a way that may be valuable to you.

  • So with this, let's go over the work bed count will show you the components you need for this particular project.

  • Then we'll go to the code that will put it all together and show you how it works.

  • So here are the major component that we need for this particular project.

  • We have our 16 by 12 LCD screen.

  • We of course, we have our Arduino, you know, bored.

  • Now again, most aren't.

  • We know boards should be able to work with this project, but we're going to need a lot of digital pins in order to make the lcc screen work s.

  • So that's the only place where you may run into issues.

  • If you're using a smaller, you know aboard.

  • Beyond that, of course, we need our little analog temperature sensor.

  • We don't need a potentially ometer.

  • The penitentiary ometer is used essentially for contrast on the LCD screen, we need 1 212 a 220 ohm resistor again for the LCD screen and we need a nice bread board.

  • Put all this together So this in this particular project, you actually do need a full sized bread Board versus a small Brad board because we need a lot of room in order to build this this thing so that we take a look at what the project looks like when it's all built.

  • And basically what we have here is the standard LCD screen project.

  • So everything here and above is the standard LCD screen project.

  • And then here, all we've done is added a tiny little in a low temperature sensor.

  • We've added the output from the temperature sensor to go over to the analog port over here, and this is basically what we've got again.

  • If you need to figure out how to set up the LCD screen, we have a class on the LCD screen to go take that class.

  • There's a whole bunch of they've got.

  • They've got six different digital wires that go to a pull, the whole other.

  • A lot of other things they're going on, so we won't go into that today.

  • Basically what we're looking at the additional components project because we're simply adding the analog sensor again.

  • Remember, when you're looking at the analog, censor it.

  • The flat side is towards you.

  • It's towards you than the left hand side, the left hand side.

  • That's positive.

  • The right hand side is negative.

  • And the centre pen, That is for the signal that again we'll go over to an analog.

  • We have analog zero today if you swap the power.

  • If you put positive the negative negative positive, you most likely will fry your sensor.

  • So, as always, by your analog temperature sensors by the dozen, that'll that'll be good for you.

  • So this is the basic project.

  • Let's go over and take a look at the code.

  • So here's a code for this project.

  • All we're really doing here is we're combining the basic LCD screen project that we've done before with the basic analog temperature project.

  • We're combining those together in order to create this particular project.

  • The first thing that we need to dio is we need to include the library for the liquid crystal display so that the sketch actually knows what we're supposed to do with that display.

  • So we do pound include liquid crystal dot Take the first thing we're gonna do then after that is we're going to define the sensor pin.

  • So again we have the analog temperature sensor pen.

  • We actually need to define that for the sketch.

  • And so we're going to do sensor pen and we're going to attack that to pen a zero analog zero.

  • They were going to go down here.

  • We're going to define all of the pens that require for the LCD screen.

  • So this is the single pin that's required for the analog temperature sensor.

  • All of this right here is required for the screen.

  • So Rs 12 into 11 before five D 546 to 3 87 2 So these are the digital pens on the right.

  • These correspond to depends that are on the LCD screen.

  • And so digital pen to will be connected to D seven pen on the LCD screen.

  • Then we come down here we call Liquid Crystal, and then we give it all this information.

  • So LCD parentheses and basically you plug all this in there, and this tells the LCD screen where it should be expecting a certain parts of data to be coming from.

  • Then we go down here and we set up the environment.

  • All we're going to do is we're going to do L C d DOT begins so essentially, we have to start the LCD service and then we have to tell the hard way.

  • No board what kind of LCD screen it is, how big the LCD screen it is.

  • And so this is a 16 column by two row screen, So 16 across too high, and then we're gonna come down, and we're going to run through the loop and actually do the code that makes all of this work.

  • So the first thing that we're gonna need to do is the basic math required in order to get a temperature out of the analog temperature sensor.

  • So whenever we're dealing with an analog temperature sensor, essentially you can copy and paste this code.

  • This is the more last the exact same code.

  • We're always going to use eso.

  • We have an ent for reading.

  • The reading equals analog read for the sensor pen.

  • We're going to then create a float for voltage.

  • Bolted equals reading times five were then for voltage.

  • We're going to divide the value of voltage by 1024 then set the value of variable voltage to whatever the result is.

  • Then we're going to create the temperature, see and the temperature f We're doing floats again.

  • Floats are decimal point numbers, So 10 dot to 70.35 That's everything.

  • Temperature C equals voltage minus 0.5 times 100.

  • And then order get temperature.

  • Fahrenheit temperature F We have temperature.

  • See times nine divided by five plus 32.

  • This is all of us Rode math again.

  • You can literally copy and paste this.

  • You're most likely not really gonna change it for anything.

  • Then we're going we're going to do is we're going to come down here and essentially we're just going to print out those results.

  • So we're gonna print out the temperature and Fahrenheit, and we're going to print out the temperature in Celsius.

  • We're going to LCD dot set cursor.

  • So we have to tell the LCD screen where we're going to start printing whatever it is that we're going to start printing.

  • So we're going to start printing at zero.

  • So this is the first position in the column.

  • So remember, whenever you deal with LCD screens, the numbering starts at zero.

  • And whenever you're doing the set cursor or anything else, remember it's column column, first row second.

  • So this is 0 to 15 right?

  • And then this is rose 0 to 1 in this particular thing.

  • So here what we're saying is positioned one position one, row 100 Then we're going to do LCD, not print.

  • We're just going to do a simple, you know, double quotation marks, temp in F space, double quotation marks.

  • Then what?

  • We're going to have to do it again.

  • This is where it gets a little weird without also the whole thing with setting the cursor.

  • So we have to figure out how long, Mrs figure out how long this is, and then we have to figure out where we're going to start printing the value for the variable for Fahrenheit.

  • So we have to do is LCD dot set cursor.

  • And if you do the math, you figure out you have to be in the 12 position.

  • So after you do temp in F.

  • Cole.

  • And if you count all that out, all the all the spaces that takes, you realize that takes 11 spaces, then you needed an additional space.

  • You know, a gap between what you're saying and the value of variable.

  • And so that gives you 12 So again, whatever you're dealing with, the LCD screens numbering stars at zero.

  • So if you want text to start being written any 12 position, you need to tell it.

  • 11.

  • So what we're saying here is in the 12 start writing this text in the 12th position of the first calm their first round.

  • So it's it the 12th column of the first row.

  • We do LCD dot print and then simply the value of temperature F.

  • They were going to go down here and for temperature.

  • See, we're going to do LCD dot set cursor.

  • And so for this, we want position one of the columns of the column again.

  • Zero through 15 or one through 16 16 spaces so that zero through 15.

  • So in the first position of the column in the second row, so Row one is a second row.

  • They were going to do LCD dot print and then Tempus Temp N C.

  • Then, in order to print the value of the variable temperature, see, we're going to go to the 12th position in the column of the second row, and then we're going to print temperature, see, then what we're going to do is down here.

  • We're then going to DeLay by 2000 milliseconds, which comes out to two seconds, and then it'll loop through again.

  • Again, again.

  • This is one thing is when you're doing these displays, especially with any kind of number, that may may be a little bit variable made, made very pretty quickly.

  • You do want to put some delay in here.

  • If the delay is not long enough, you'll actually get a blurred number.

  • And the reason for that is the number is literally changing so quickly because remember that this loops literally as fast as the Arduino can loop it.

  • And once you put a delay in there, so if you have a number that's changing every millisecond over a couple of milliseconds, the display is gonna change over a couple of milliseconds.

  • And what you see is a human being is basically a blur.

  • So you have to figure out like what you want the delay to be.

  • I'm putting toe delay of 22 seconds.

  • I think that's very reasonable for for a temperature project, so that will upload it, and I'll show you the results.

  • So here's our little project.

  • I'm going to plug it in.

  • So this thing has power, Okay?

  • It comes on.

  • And you look at that.

  • We see temperature.

  • So we see temperature and fair knight 65 5 and we see temperature and Celsius is 18 85 or so.

  • If I put my finger on here, basically, we'll see that the temperature starts going up so again, about every two seconds.

  • So there goes to 66.

  • There goes to 60 acre, there goes to 72.

  • And then if I take my finger off, then it should start dropping down again so you can see that this is dynamically changing approximately every two seconds, based off of the value that is receiving from that analog temperature sensor.

  • So this is just a very simple way to be able to see how to display both static text and the values of variables using an LCD screen again.

  • It's a nice, simple project, but this is one of those things that could be relatively useful again.

  • If you just need a simple just a simple temperature sensor or whatever in your server room or such, this may be valuable for you.

  • So that's all there is to using an analog temperature sensor and writing the output toe a little LCD screen.

  • Now it is important.

  • Understand?

  • You know something to be thinking about when you do these Arduino projects is remember, all you're using is just basic copper wire to connect all these components so you can do things such as Put this into your computer case, so I know.

  • No, I know a lot of what the what?

  • The cool kids.

  • I'm not a cool kid.

  • I'm not a cook.

  • It, but a lot of cool kids out there really care about the temperature inside their gaming PC.

  • Like you have a gaming PC or sought some high end rendering PC, you may want to know what is the temperature inside the case.

  • So a lot of times, if you have something like that, if you have a PC, you'll be able to read things like the temperature of the CPU.

  • Or you may be able to read the temperature of the GP use.

  • But you just may be curious about what is just the internal case temperature.

  • And so one of the things that you can do is you can just simply connect this little analog temperature sensor, you know, connect the wires.

  • You may want to saunter them, but, you know, even if you don't start a room just electrical tape at the high hell tape all the wires to it, Basically, you can shove it in your case, and then you can have a nice little display sitting on top of your case.

  • And you know, what is the temperature inside the case?

  • You know, those types of things to be thinking about with these kind of projects is just, you know, not not just the Sanders.

  • Oh, OK.

  • I now know what the temperature is inside inside the room, but basically the idea here is Hey, you can figure out things like, What is the temperature inside your computer case or your server case or other different types of things?

  • That's a type of stuff that might be valuable.

  • And have you do a project like this?

  • So that's really all there is to it.

  • We're gonna be doing a lot more projects special with the LCD screen and always with the analog typical sensor, you have to say, and long temperature sensors are just really great for a casino projects he was a very simple way to be able to input variable data into your projects.

  • So we're definitely gonna be using these components more going into the future.

  • As always, I enjoy doing this video and look forward to the next.

Please go to the line.

字幕と単語

動画の操作 ここで「動画」の調整と「字幕」の表示を設定することができます

B1 中級

16 x 2 LCDとアナログ温度センサーをArduinoに搭載 (16 x 2 LCD and Analog Temp Sensor on Arduino)

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