Master OLED Displays with Arduino, ESP32: A Complete Guide

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in today's episode I'm gonna show you how to use the OLED display I'm going to show you how to hook it up to an Arduino board like the Arduino Nano but you could use other boards including the esp32 microcontroller because it uses the i2c communication we have the SDA and the scl pens that we need to hook them up to the board here we have a circuit schematic diagram that shows you how to use this displays it is called OLED display and it stands for organic light emitting diode this is 128 by 64 pixels display if you have another size you could use it with the same way as I said it is using the i2c communication we connected the scl to the scl of the board for an Arduino it is the analog pin A5 the SDA goes to the sca which is A4 and this displays needs a little bit of power by connecting the VCC to the 5 volt pin for an Arduino Nano it is the VN this pin outputs 5 volts the gnd goes to the gnd some old LED displays comes with another pen and it is called the reset pane you may need to connect it to one of the digital pins like DPA number five for me it doesn't come with this fifth pane once you connected the OLED display we can move on to the Arduino IDE first of all you have to install two libraries so that you can use this kind of displays by going to tools manage libraries and let's search for the first one just write SSD 1306 and that's the name of the OLED display and the library that we need is Adafruit SSD 1306 by Adafruit make sure to install it using the install button the second one is called gfx and search for adfruit gfx Library I've already installed it using the install button once you do that we can open up an example sketch by going to file then examples under here we have the name of the library Adafruit SSD 1306 we have different options for me I have 128 by 64 display and it is using the i2c communication before we upload the sketch you may need to change few parameters like the OLED reset pin for me it doesn't come with a reset pen I'm gonna leave it as default -1 then you have to set the address of the OLED display and it could be 0x3d or 0x3c I've already used this address but it doesn't work that's why I'm going to select the second address then we can select the right board for me it is an Arduino Nano and let's hit upload we have these cool animations to test the OLED display and I highly recommend you to read this sketch like displaying images using this array here we have an empty sketch I'm going to show you how to use this display but let's copy a few things like the libraries that we need we've already installed these two libraries and this is built in and it is used for the i2c communication then we have to create an object of type adfruit SSD 1306 I will just copy it then you can give it any name you want like display in this parentheses we have to set few parameters the first two parameters are the width and the height so I have 128 by 64 pixels display then we add and and the name wire and this object will use it to set the i2c communication the last parameter is the reset pane for me I'm going to set it to -1 because this display doesn't come with a reset pane under the setup function we have to start this object or initialize it using display then dot begin and this takes two parameters I'm gonna copy them from this main sketch the second parameter is the address I'm gonna pass it in directly 0x3c as I said if it doesn't work you have to use 3D first I'm going to show you how to display a text using this display object but before that you have to know few functions like display then dot clear display to make sure that we have an empty screen before we start writing any kind of text we have to set few parameters using display then Dot and use set text size to set the text size this takes a value between 1 and 8. let's try with one then we can set a color using display dot set text color and use white make sure it is all uppercase the next function is used to set the cursor position set cursor I'm going to select 0 0 which is the top left corner next we can use the function display.print or println to go back to the next line like Hello World last but not least in order to apply these changes we have to call another function using display and it is called display and that's how we can write text using this kind of displays and there you go we have hello world I think I'm gonna change the size let's set it to three the letters are bigger now let's try to display some cool images to do that first we have to resize it to the same size of the display which is 128 pixels by 64 pixels and open it with paint if you are using Windows and let's set the size 128 by 64. and hit OK but we can take this image under our code we have to convert it into an array that will tell the display to change the value of the pixel and to do that first we have to save this new image using file save as like PNG you could go to this link I'm going to add it under the video description then we can select the image using choose files it is under my desktop you could also see a preview of the result I'm gonna adjust the threshold so that we can see the logo much better than to get the array of pixels we have to use Arduino code then generate it let's copy it using copy output I'm going to create it under here using Ctrl V we don't need these variables we only need this array let's change its name to a simpler one like logo array if you want to display an animation you could use the loop function first we need to clear the screen using display dot clear display then we have another function draw bitmap this function takes few parameters like the position from where we're going to start drawing the image I'm going to use 0 0 then the name of the array I have called it logo array then we set the size which is 128 by 64. and finally the color I'm gonna use one which means white to apply these changes we have to call display then dot display let's check if it's working and there you go we have the logo of our Channel I think that's pretty much it guys for this video I hope you like it if you have any question or comment about this kind of displays make sure to write it under the comment section down below and they will see you in the next one
Info
Channel: Enjoy Mechatronics
Views: 35,905
Rating: undefined out of 5
Keywords: Arduino, tutorial, enjoy mechatronics, how to, microcontroller, electronics, getting started, esp32 beginners, esp32, introduction, beginner, learn, basic tutorial, basics, arduino, esp32 arduino, oled arduino, oled arduino projects, oled arduino tutorial, ssd1306, oled temperature display, arduino uno, oled, oled display, OLED display, programming, graphics, animations, I2C, SPI, electronic engineering, prototyping, DIY projects, small displays, embedded systems
Id: jIQSlYtGWTI
Channel Id: undefined
Length: 8min 11sec (491 seconds)
Published: Tue Feb 14 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.