LCD Basics for the Pi Pico

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
howdy tinker nerds today we're gonna learn how to connect an lcd to the pie picot smiley face paper rock scissors shoot man you're good if you want to keep those knowledge gears greased please be sure to subscribe and ring that notification bell last week i introduced you all to the pie pico but now it's time to move beyond introductions and do something useful with this thing let's give it a face to do this project here's what we're going to need raspberry pi pico obviously a 16 16x2 lcd screen with an i2s adapter header pins a breadboard some jumper wires and some soldering equipment so let me begin by saying that you can't just use any lcd with the raspberry pi pico it has to have one of two things number one it has to have the right connectors and number two it has to have a supported library for the raspberry pi pico in order for it to work that's why i chose this simple display to start with now don't get me wrong the raspberry pi pico can support a lot more complicated and different types of displays but if you're a beginner i recommend going with this one these little 16 by two lcd character displays are very basic and they were one of the first types of lcd displays ever to exist and if you want to learn more about them and even how to control them without any type of computer then you can watch this little video by the 8-bit guy on his channel the problem with these lcds for beginners are all these different types of pins now can you control this from the pico yes but there's a much simpler way to do it if you use this little i2c adapter i2c is nice because it reduces the amount of pins from 16 to 4 and i2c is a much simpler way to communicate with the pie picot now we need to connect this lcd to the picot and the standard way of doing that is by attaching them both to a breadboard and connecting them using jumper wires to do that we need to solder some header pins to our picot i put the header pins in the breadboard first and just to hold them in place and then i placed the picot on top of them and soldered the pins to them now soldering is a fairly simple skill you want to place the hot soldering iron next to one of the pins to let it heat up then you can touch some solder to the other side of the pin to let it melt and once the solder has covered the pad and the lower portion of the pin you can remove the soldering iron and the solder now wiring up the lcd is simple just make sure that the lcd is supplied with the proper voltage it needs to run in my case that's 5 volts so i'm going to be using the v bus pin or pin 40 on the pi pico and then the ground goes to the ground pin on the pi pico and the sda pin goes to sda 0 or pin 1 on the pico and the scl pen goes to scl0 or pin 2 on the pico with the wiring done we can now press down the boot select button on the pico and plug it into our computer then open up thoni python editor and let's get to coding so it would be nice if you could just bust out some code to make the lcd do stuff but before we can do that we have to find libraries and drivers for the lcd that we're using libraries and drivers are a set of code that provides us with the core commands and functionality to get our lcd working without them it'd be like trying to drive a car without an engine searching around i found the github user t-622 posted a nice port of an i2c lcd driver for the pico you could copy and paste the contents of each dot py file but if you're git user you can also just clone the repository to your computer then open up each dot py file in thoni from your computer and then save them over to the pico using the exact same file names now before we can run a test file we have to check one thing using the i2c protocol requires us to enter in the address of our lcd screen so what we can do is create a little address finding script and then check it for errors and save it to our pico and then just run it the result should be your lcd's address and in order to use it we first have to convert it from the current decimal value to a hex value and we can use this online converter to do so it just so happens that my lcd address is the same as the one in the demo script so it should be fine to just go ahead and run it and see if it works now that we got the demo working we can write our own custom script to make it do the things we want it to do i'm just going to create a new script and copy over the header of the demo script to mine then you also want to copy over these two lines from the main loop that declare the i2c and lcd variables using the clear command clears the lcd screen of anything that's on it and using the move 2 command moves the cursor so 0 0 moves it to the top left corner 1 0 moves it to the next character in the first row and i'm just going to move mine over five characters and then use the put string command to write my word string onto the screen keep in mind that you're limited to 16 characters per row now i'm going to move my cursor over one character on the second row and write my next word string the u time sleep command pauses the program for however many seconds we want the text to remain on the screen before continuing the program so let's stop here save it to the pico as my underscore lcd.py and run it to see what we get perfecto but what if you wanted to display more than just text characters what if you want to draw your own characters on the screen well there's a cool utility online called the lcd custom character generator that lets you basically draw your own custom characters i'm going to draw half a smiley face and then it outputs the code for that character just make sure that your code is set to hex and then you can select and copy those hex characters and back in our program we can use the custom car command to create our own custom character and assign it a number value and then use the byte array value to paste in and store our hex value next i'm going to invert this character copy over the hex values and store them as another character and i'm going to repeat these steps for the second half of these smiley faces storing them all as custom characters now i can move the cursor where i want the first character to be and i can use the put card command with the assigned character number that i want to use testing it out i've now created my own custom characters so there you have it that is the basics of using an lcd with the pi pico that should be enough to let you create your own custom code and variables that you can use in your own projects how would you use this on one of your projects let me know in the comments below you can click here to watch more videos like this and please remember to support me by sharing liking subscribing or commenting until next time keep tinkering [Music]
Info
Channel: Tinkernut
Views: 31,567
Rating: undefined out of 5
Keywords: tips, tricks, tutorial, tinkernut, how to, weekend hacker, gigafide, tinker, raspberry pi pico, pi pico, raspberry pi, diy projects, raspberry pi projects, raspberry pi pico projects, lcd, lcd display raspberry pi, lcd display, pico display raspberry pi
Id: B8Kr_3xHjqE
Channel Id: undefined
Length: 7min 30sec (450 seconds)
Published: Sat Feb 20 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.