Arduino Projects

Arduino SSD1306 Oled Display Module- Circuit diagram and Programming

Arduino Oled Display, Example:

In this example, I am going to explain how to use an I2C-supported SSD1306 Oled display module with the Arduino. For the demonstration purposes, I am going to print the Potentiometer value on the Oled display module.

Arduino course

Potentiometer is still connected to the analog pin A0. The VCC and GND of the Oled display module are connected to the Arduino 3.3V and GND pins. Whereas the SDA and SCL pins of the Oled display Module are connected to the Arduino Analog pins A4 and A5 respectively. A4 is the SDA and A5 is the SCL. Now, let’s go ahead and take a look at the programming.

allpcb circuit




Amazon Links:

Arduino Nano USB-C Type (Recommended)

SSD1306 Oled display

*Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.



Arduino Oled Display Library Installation:

For the SSD1306 Oled display module first you will need to install the libraries and then you can use the header files. For this simply go to the Sketch Menu, then to Include Library and click on the manage libraries. Type Adafruit_GFX in the search box and install it.

Arduino course

As you can see I have already installed this library. Next, search for the Adafruit_SSD1306 and install it.

Arduino course

As you can see I have also installed this library.



Arduino Oled Display Programming:

I started off by adding the header files.

Next, I defined the Width and Height of the Oled display module. The type of the Oled display module I am using doesn’t have a reset pin so that’s why the OLED_RESET is set to -1.

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

This line initializes an instance of the Adafruit_SSD1306 class named display. The constructor takes four arguments.

Potentiometer is connected to the Analog pin A0 named as pot and the potvalue variable is going to store the value of the potentiometer.



In the void setup() function, you can see I have activated the Serial communication and this time round I only used it for the debugging purposes. The potentiometer is set as INPUT. This line activates the Oled display module. 0x3C is the I2C address you can use the I2C scanner code to find this address. You can download that code from the Article. Anyway, then we clear the display and set the text color to white.

In the void loop() function, we simply read the Potentiometer and store its value in the variable potvlaue and then using these instructions we print this text and value on the Oled display Module. You can set the font size, and using the setCursor you can select any position, and using the display.print() function you can print strings and numbers on the Oled display module.

Arduino course



video tutorial

 

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button