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 a previous video, I did a demonstration showing why Oh led screens for our DWI knows are such cool things.

  • So when the video today what we're going to dio is I'm going to show you how to print text out to an O led screen.

  • So this is slightly different than when you're going.

  • Be printing out to an LCD screen because with O.

  • L E D screens, you have so many more options now it isn't port.

  • Understand?

  • We're printing out toe Anno led screen.

  • We can print out a whole bunch of things.

  • We can print out bit map images.

  • We can print out scrolling text.

  • We can do a lot of fancy things that you can't do with LCD screens.

  • But today all I'm going to show you how to do is print out text because realistically, that's probably going be the most important thing to Dio when you're dealing with your projects.

  • So what we're going to be doing today?

  • There are simple little project is the first thing that we're going to do is we're going to print out a sample splash screen Splash screen is something that pops up essentially whenever you turn on a Elektronik device or a computer, and many times that splash screen can tell you information that may be imported.

  • Now it may be a logo or something like that.

  • You're dealing with a large corporation alarm vendor.

  • But for you, if you're creating custom little widgets, maybe for a splash screen, you want to put something such as a phone number or what to do if there's a problem, so we're gonna do is we're gonna throw a little splash screen.

  • Then, after 5000 milliseconds, five seconds, then we're going to print out a simulated a network tester so it's going toe across the top.

  • It will have a title of net test is if this is a network tester and then we'll actually say I p Colon 1 92 don't want 68 at 1.1.

  • The sum that gateway, the D.

  • N s one in the D.

  • N s, too.

  • So for this, I'm simply plugging in strings because I'm trying to keep that simple as far as this project goes.

  • But if you're trying to create, let's say, a network tester device using Arduino, you could put in the actual values for the variables there.

  • Print out the valleys for the variables rather than simply pretty out text like we're doing today.

  • So let's go over the work bench.

  • So if you could just show you how this project is assembled and then we'll go over, take a look at the code and then I will demonstrate how all of this comes together.

  • So today we're using our standard of 1 28 by 64 0 led screen that we've been using for the projects and were simply connecting this to the Arduino.

  • Now again, since this is an eye to see or a nice square to see Ah, screen.

  • We only need two wires before the data.

  • So we have two power wires and two data wire.

  • So we're using the five volt and the ground, and that goes to BCC and ground on the O led screen.

  • And then for the S C l s C l goes to a five on the Arduino and s d a.

  • Then goes to a four.

  • And so these air not actually defined within the script.

  • This is just something that you normally do whenever you're using the I square see protocol and order to communicate with I square See devices.

  • So just keep that in mind.

  • That s c l then will go to a five s d a.

  • Will go to a four, and that's really all we need in order to assemble this project.

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

  • So here's a coat for this project.

  • Essentially, we're just setting up the environment.

  • And then what we're going to do is we're going to print out a splash screen and then from that splash screen, we're going to go into a loop, and then we're going to do a simulation of a network tester s.

  • So the first thing that we need to do is we need to include our library, so we need to include the wire, not eight library.

  • So that's included by default with the aren't we?

  • No, I d e.

  • Then we also need the added fruit SSD 1306 library and the out of fruit G f X library.

  • So I talked about those in the demonstration video.

  • You're just not going to need to add these libraries again when you go to install the s s d 1306 library and make sure you install the ad.

  • A fruit library.

  • Ford.

  • There are a few different libraries out there.

  • And if you install a different library in this particular project won't work.

  • So make sure you install the 14 out of fruit by at a fruit to make this work again.

  • Even though this isn't an ad of fruit.

  • Oh, led.

  • It's actually no.

  • Oh, led from D I Y the ad a fruit library works, so make sure you get that one.

  • Then we're gonna come down here.

  • We're simply going to be fine.

  • And we're going to find the O led a wit and the O led height.

  • Eso How wide is it?

  • So how high is it?

  • So this is 1 28 pixels by 64 pixels.

  • Then we're gonna come down.

  • We're going to find we're going to find the O led address.

  • Remember the I square See address.

  • This is an addressable protocol, so you could have.

  • I think it's up to 127 devices.

  • They're radically connected in those two little wires and you differentiate between them all using an address scheme.

  • Kind of kind of sort of like an i p address, please.

  • Maybe more like a Mac address scheme.

  • Really?

  • But the important thing is you need to know what the hell that address is.

  • Do you plug that address in here?

  • You don't know what the address is.

  • I did a project before with the I square.

  • See, or to see scanner.

  • So simply do that project scan to find out what the addresses and then plug that address in here.

  • If you don't play in the right address, this project simply won't work.

  • We're gonna come down here and they're going to use the ad of fruit.

  • Underscore SSD 1306 To create the displays, you can call this whatever you want.

  • You can call this O l E d oh, led display.

  • You can name this, however, but this is how you will reference the display going forward.

  • So this is important.

  • So let's say you had multiple displays on your particular project, then you would want to name them differently.

  • So here we're simply calling this screen display, and then we're going to feed it the O led wit.

  • And in the O led height, So were created an item called Display with this this with and this height.

  • And so that's what we're doing in the first part of this project.

  • And we're going to come down and we're going to go into the set up for the environment here.

  • The first thing that we need to do is we actually need to begin at the display.

  • So we're going to reference display, so display dot Begin.

  • Then we're gonna plug in this S S d 13 or six underscore switch cap vcc.

  • And then this is where the oh led address goes.

  • So the oily, the address that we defined up here gets blowing in here.

  • So theoretically, you could just simply write in type in zero x three, see there, and it would work.

  • But we're just referencing that variable so it could change.

  • Then the first thing that we're going to do is display dot clear display function.

  • So remember, especially when you're doing dealing with screens in the Arduino world.

  • Things don't happen automatically.

  • You actually have to tell them to do things.

  • So if you turn on a pixel on a screen, you also have to remember to turn off that pixel or you're going to start running into problems.

  • And so this clear display function that will clear basically, that essentially cleans the entire screen and you start from square one.

  • So we want to turn off all the pixels on the O L E d.

  • And that's how we do it.

  • Then we're gonna come down here and we're going to display dot set text size so you can set the size of the text that you're going to print out.

  • This is from 1 to 81 is the smallest eight is the largest, and it gets pretty big on 1 28 by 64 screen.

  • So we're simply going to set the default size at two.

  • Now, to be clear, this isn't too as in what you would see on a computer screen.

  • It's two in regards to the O led screen, so this is one not bigger than one.

  • Then we could do display dot set text color so you can set the color of the text.

  • Now again, if you have and oh, led screen that actually does multiple colors, then you can put in different colors here with the old led screen that we're using its kind of sort of a two color screen.

  • Basically, what that means is the top.

  • A bit is yellow and the bottom is blue.

  • So, basically, whatever you're printing, it's always gonna be white.

  • It's no.

  • And so when we say white, white is the default color.

  • So when we print out white and the yellow bit, then it's yellow.

  • If we print out white in the blue bit, then it's blue.

  • So white is kind of like that default color, but you can set the text color here.

  • Then what we're going to do is we have to actually set the cursor.

  • So, just like with LCD screens, we have to say where we're going to start printing at so display dot set cursor function, and then we have zero and 17 so zero is the column.

  • So when you're going a left to right, basically zero means the first position on the left.

  • So when we're dealing with text, we're dealing with these screens.

  • Thief First position is actually zero.

  • It's not one through 1 28 It is, in fact, zero through 1 27 were going to say is at the first position to the left, and then we're going to say essentially zero the first row.

  • So this will plug us up at the top.

  • So this is the first place will be a prince.

  • So with 00 position at size to act color white, we're going to print out.

  • Welcome, Then what we're going to do past that is we're going again.

  • We're gonna display we're gonna set the text size.

  • We're gonna leave this as two.

  • We're gonna display dot set text color to white so you can modify this here.

  • I haven't modified this, but I just left it there.

  • T kind of grasp.

  • What's going on then we're going to do is display, not set cursor.

  • So we're going to set the cursor to a new position.

  • And so now we're going to set the cursor to the zero to the first position on the left, and then we're going to go 17 down.

  • So this starts at the first position down now we're gonna go 17 positions now then, from here, what we can do is we can actually start printing much like we would print on a serial printer.

  • Right?

  • So we can say display dot print line.

  • So print line means print this and then go to the next line so we don't have to set the cursor again as we're printing this stuff out.

  • So at the size to we're going to print line, this is we're going to go down on the next line, a splash and on the next line screen on DSO that's gonna print out.

  • So that's an important thing to realize.

  • One of the nice things with O.

  • L E.

  • D S is once you set that cursor position, then you can simply do print line to print on the next line of print on the next line to print on the next time.

  • You don't have to set the cursor position for every single line printing, too.

  • And in the final thing function here is one that you definitely don't want to forget.

  • So it's gotta interesting how the old lady screen works.

  • Basically, what's happening up here is that all of this information is being loaded into the memory of the screen, so it's simply in the memory of the screen.

  • It doesn't get automatically written to the screen.

  • What you have to do is you actually have to use this display function.

  • So display dot display.

  • So this is a display function here.

  • And what that does is that then writes what is in memory to the screen so literally you can do all the rest of this.

  • But if you don't finish off with this display function, then then it's simply not gonna record the screen.

  • So display is what we're referencing.

  • So this could be called Oh, led.

  • This could be going Oh, led display.

  • This is the name of what you're referencing, period.

  • And then this is the display function.

  • So I want you to make because this here could be a little confusing.

  • So I just realized this is the function.

  • This is what you're referencing.

  • And then for here, we're going to delay for 5000 milliseconds or five seconds.

  • So again, So this is going to be a splash screen, so it's gonna show up.

  • It'll be there for five seconds, and then it will drop into the loop.

  • Now, again, this is basically just a simulations are not gonna do any fancy coding here.

  • We're just simply going to print out some more information.

  • So the first thing that we have to do is again display what we're referencing and then clear display.

  • So what we need to do is we need to delete that splash screen that we just created.

  • That's the very first day, literal.

  • If you don't do that, everything gets printed over top of each other and it just literally becomes a mess.

  • Then the next thing that we're gonna do is displayed not sex, a set text size.

  • And so we're going to set that to two like we did before.

  • Set text, color.

  • We're going to set that white like we did before, set cursor again to the 00 position, and then we're going to display, not print line or print net test.

  • So this is simply going to be a net test then what we're going to do is we're going to come, go, go down, and then we're ready to do display that set text size.

  • And so here we're changing the text size.

  • So This is for the title of what we're doing.

  • This is for the important information.

  • And so for here we're going to set the text size 21 This is the smallest size.

  • Then we're going to set the text color again to white, then display, not set cursor.

  • So what we're gonna do here is again zero, and then we're going to go down to the 70.

  • We're gonna go down 17 Rose, and then what we're going to do is we're simply going to do display dot print line, and essentially, we're simulating a CZ.

  • If this was a network tester, so print line the i p with the i p address, display that print line the sub net display that print line the gateway display that front line D.

  • N s one displayed up front line D.

  • N s, too.

  • So basically all of this will show up on the screens, will be able to print on that out and again, If this was a really network testing thing, you would be printing out the values of what it's a scene instead of basically these strings.

  • But we're just doing this as a test and then finally as said before, We need to do the display dust display function so that this prince everything that is in memory.

  • So remember clear display clear display erases the display.

  • So you need to use that.

  • And then once all of this code has been written, that you then need to call the display function to actually print all of his information from memory on the O led screen onto the screen itself so that let me connect, there'd be no project.

  • Upload the code, and I will show you how this works.

  • So here's our little project.

  • I'm going to plug it into the computer and then we'll see the screen.

  • So welcome.

  • This is a splash screen to get your nice little splash screen there and then we have net test.

  • So it's a little hard to see because it's kind of hard to focus.

  • But let me tell you, in the real world, this is absolutely clear.

  • Well, you can see is in this too.

  • So this is the two fought size.

  • We can see net test and then under that at the 17 position we don't have I P says 1 $92 68 1 dot what it says some that 255255250 And it says gateway, whatever it is one of the 2.16 You don't want one D.

  • N s.

  • 1 100 to 1 succeed I want to.

  • And Ian has to 1 92 to 1 68 1 not three.

  • And again, I know, I know trying to get this through the camera and maybe a little foggy to see.

  • But I swear to you, in the real world, this is absolutely clear and very easy to see a CZ long as you have good eyesight.

  • Now do you remember?

  • Do you remember?

  • This is kind of small again.

  • This is the size of an LCD.

  • This is the size of simply a two row LCD screen versus versus this S o.

  • Do you realize that the text on here is incredibly small, But as long as you don't need glasses, it's pretty easy to see.

  • And so that's related.

  • That's all there is to this project.

  • Thio be able to see how this works.

  • You're able to print out with a text again, have something like a spot of screening.

  • We'll go here now.