OLED Displays EXPLAINED! | Arduino Sensors | #grindreel

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
this is an oled display very similar to the lcd display we've used on many projects before the outlet display is just more accurate and it uses a bit of different technology personally i think it looks a thousand times better than the lcd display here's two pictures up on the screen of what the outlet screen will look like later in this video and then lcd screen that we've used before so on our oled screen we have 128 times 64. and while on the lcd screen we also have pixels and we can control those pixels we use this usually as a character display there are 16 by two characters that you can type in here so we've done like hello world or we've used this as a timer or as a clock before and that's usually the use case for this with an oled screen you can go and control the pixels and do whatever you want you can draw a picture on there you could draw shapes you could do animations things that you can't really do that well on the lcd screen also we should note that you can do really small font on here for letters and you can fit a bunch of text and it's also like what a fourth of the size of the lcd supply so it allows you to display a bunch more information animate it fit it on a smaller platform use less pins to activate it less power to activate it and it's about the same price as an lcd display so personally this one goes to the garbage and this is the one that we use there are situations where you'd still use the lcd display and it's still very useful and all that but i'm a real big fan of these because they look so cool you can even go as far as getting a colored version of this this one is just white and black and you can invert those colors but you can go and get a colorful version of this and make you know one pixel green one pixel blue and pixel yellow purple whatever color you'd like and draw some things on the screen the way it works is it's actually really simple it has four pins on the top ground vcc scl and sda ground and vcc as every sensor video i've made in this channel ground is to ground vcc is to power in this case you could do three volts or 5 volts i'm going to be doing 5 volts in your scl and sda we've done these before on the lcd screen scl goes to 4 analog 4 and sda goes to analog 5. so my board isn't actually soldered to the cables so i'm just going to stick them through and let it loosely sit on them ground vcc scl sda ground 5 volt analog 4 analog 5. that's the pin out that's the schematics that's how you do it now once you got your board plugged into your arduino through the cables and the pin out that i've showed you go and open up your arduino editor and let's go and start writing the code for this module so here are the three libraries we're going to be including in our project we can actually go and make this a little bit larger we have the sbi library the wire library and adafruit ssd1306 library that's because that's what the name of the sensor we're using is called if you're getting an error when you're trying to upload the code saying these libraries are not included not found whatever it is go into your tools and into manage libraries search up ssd1306 so let's go do that quickly and you should see one right over here by adder fruit for this specific module the first thing you have to do is go and declare a couple different variables first thing we're going to do is just copy this x is going to be your horizontal pixels so in this case the sensor is 128 times 64. depending on the type of board you're using you need to declare the reset pin so for this board it's negative one if you're using a different board just search up what number port the reset button is plugged into but in this case it's negative one so we're just going to do that and now we can go and actually call this library you can just copy paste that right here and then we can type in display and here we can put in the numbers we just declared so we have x y the third thing is you're going to have to be including your wire library and before you put the wire library just put this little symbol here that's just pointing a reference to the library instead of actually copying it and putting in a new instance in there and then go and call your reset so now we're telling it the board is 128 times 64. you give it the wire library and then your reset pin which is just r is going to be the number which when this gets activated we're going to be resetting the screen now we can go and do whatever you want so in setup i'm just going to quickly set up my serial dot i'm gonna have you guys type this little section out first and then i'll explain exactly what it does so just pause the video take a second what the section is doing is grabbing the address of your module and then it's checking if it works if it can find it and if it's being able to display anything onto it if you see this error you might have the wrong address for your module which is this little number here 0x3c if you are getting this error i'm going to post a file in the description to the github link just take that code we can even do it right here just paste it into your arduino editor so just upload it to your board and then in your serial monitor you should see a message telling you your address ic2 scanner device found 0x3c so that is your address that's the one i already have and it works perfectly for me then we can just undo all this mess and go back to our original file again the code will be in the description for you guys so you can just copy paste it run it check what it outputs and then go back to your normal the first thing you should do is call display.display and every time you do this every time you call the display method on the display variable you're telling it to kind of print think of it as print so you're giving a printer instructions and then you're clicking the button print you can tell it all right well we want to print this picture of a dog and then you press the button print that's what display.display is doing so we call it right away and it's going to run like this add a fruit like display screen just like default logo put a little delay so that it doesn't just run and then get deleted instantly and then under that we can go and clear the display now that we ran that thing that think of that as your like initial startup when you're starting up your computer you see the windows logo this is like seeing the adafruit logo and now under this we can go and draw whatever we'd like so i'm going to go and just draw a pixel so we're going to go display dot draw pixel and then here we can put the location of the pixels so let's just put it at the random location on the screen you also have to go after you give it your x and y coordinates you have to go and tell it what color to put it in because my screen only has one color which is white or you can invert the screen and they'll make it black you can go and put in white in there and then call your original display.display with a little delay let's go through that quickly we're starting the screen and we're printing out the default logo for two seconds then it's gonna clear the display and it's gonna go and draw a pixel on this coordinates a white pixel it's going to print it out for two seconds and then because we're not clearing the display after it's just going to stay there so let's go quickly and actually upload this to our board now on the camera here i'm going to zoom in really close to the sensor just because the pixel gets really really really small seems like we forgot a little semicolon here so let's just add that upload it one more time to the board if you always want to know what your error is it'll show down here again being another semicolon the second is not uploading you should see your screen put that adafruit display logo and then we can see a little tiny baby pixel over there it kind of looks like a speck of dust some dirt on it let's go back into the arduino program and grab this drop pixel and uh just copy paste it a couple times then i'm going to go into my x coordinates and just move each number by one we can go and do it five times so now we have five pixels next to each other i'm just gonna go and upload that to the board make sure everything is correct there's no mistakes all right we're good and in a minute or so we'll see that the adafruit logo will pop up again there we go that's the first display.display and then we can see that one pixel just became a little line i made this little loop and what it does is it starts at zero zero on the screen and it draws vertically a bunch of dots so it starts at zero zero it goes zero one draws a dot zero two draws a dot zero three draws it down and then once it hits all the way down to 64 it moves over one and draws another line so we can go and run this quick and you can actually see it live updating on the little screen this is the idea of how animating works on this screen so you go you make a change you display that display you make a change you display not display and then you can see it in real time on the screen so you can't really tell something to move from one place to another and then display display because it'll just put the final product you have to tell it at each point at each keyframe pretty much to go and print and this and update the screen so if you're moving one dot from this block right here onto this block right here you have to move it over display.display move it over display.display move it over display.display you can't move it all the way to the last one tell it move from here to here and then display.display because it won't show that animation it'll just print it in its final position and now as you can see on the screen it's drawing over and over a line and then it's moving over to the next drawing a line moving to the next if i went in the bottom here and commented out this right here and we uploaded that to the arduino give it a second you'll see the screen uploads so what happened here was it never showed the progress it just waited till it finished all the dots and then it said all right let's print it now the next thing we could do is go and erase this little example right here and we can go and actually add some text onto here let's go on the bottom here and just make a little function so we'll just go void hello world and then inside of this let's go grab display i should put it down here clear display under that let's go and use little text functions built into the display so we have three of them we have set text size let's go and put that at one we have display set text color like i said earlier this is just a mono color screen so we just have white capitals and then we can go and set the cursor so we're going to fill it to start right in so then we can go and grab the cursor which is just like your mouse on the blocks on the pixels until it start on pixel zero zero so it's the top left corner and then on that just like when you print in your console you just want to call line and inside of that we can just go and put a formatted hello and then we can grab this function right here call it right here so what's going to happen is it's going to display the default logo two seconds clear the display do our hello world and then display it and there we go we see hello world and it's quite crazy to see the text size difference between this board right here and using the lcd display we could fit so much more information here we can draw shapes and stuff and i can even go in here and change the text size if i'm not happy with that one to a number like two the one problem is if you make the text size too big which two is going to be too big let's wait for it to update quickly you can see that it doesn't actually fit on one lines you can also go and just tell it print line and split up those two words and as you can see now we have hello and world on two separate lines if you wanted more space in between you'd have to either move the cursor and reprint the word or add some kind of empty space in between and it would separate the two more but the fact that you can do whatever you want move it wherever you want you can put the world at the bottom left and hello at the top and have them move around is just crazy comparing to what we started on on this lcd display so as i promised earlier i told you i'd show you what full animation would look like i didn't write this i'll leave a link to below for the person who did write this on their blog page but what they do is the first thing is they have this line animation then it goes into rectangle then it goes rectangles that are getting filled then it goes into circles then it goes into circles that are getting filled then it goes into round rectangles then it goes filling round rectangles and it goes into triangles and it fills the triangles then it just goes and draws a bunch of letters and characters which is actually a really cool one it draws some different styles and then it does text animation which is what we did earlier this one is personally my favorite because this is what i'll actually be using it for and then it does the arduino logo the adafruit logo has it like fall from the sky this one actually takes forever because the person had to go and physically draw bit by bit what the logo looks like and then now they now that they have that they can go and animate it on the screen that must have taken a really really long time but that's pretty much it we're able to go and turn on individual pixels and doing that you can now and go draw a shape link it to a function and then tell that function to go and draw a shape or you can make it put text you have infinite options of what you can do here personally what i'm going to be using this for is i'm building currently a security system and this will be the display to see who just put their key card into the security system who just opened the door you can check like the status of the security system is it armed is it disarmed this will be giving you all that information instead of using like three or four of these that are huge and barely fit any information the cool thing about these little screens is that they're so small and flush you can probably grab three or four of them and then just line them up and then just tell it to put individual words on individual screens if you enjoyed this video and you enjoyed seeing this little screen animate really cool things please do give it a like and maybe consider subscribing to the channel i have a bunch of cool videos coming out now they're going to be less like this where i'm just putting my hands on the screen and more like my face and me showing you something and taking it and building it and showing you how to solder and doing like more hands-on i think these videos were really helpful but it's time to make more like robot style videos so thanks for being here hope you enjoyed and i'll see you in tomorrow's stream
Info
Channel: Mikael Abehsera
Views: 4,544
Rating: undefined out of 5
Keywords: arduino, sensors, arduino tutorial, arduino projects for beginners, arduino programming, arduino uno, arduino robot, robotics, arduino basics, robotics engineering, robotics for beginners, robotics for kids, robotics notes, robotic arm, microcontroller, embedded, embedded systems, electronics, electrical engineering, coding, tutorial, robot, LED, learn, motor, ultrasonic sensor, sensor, sound sensor, speaker, homemade speaker, diy speaker, arduino speaker, oled
Id: 0nVchCisbQ0
Channel Id: undefined
Length: 15min 36sec (936 seconds)
Published: Sat Aug 01 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.