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. Shahzada Fahad

Engr. Shahzada Fahad is an Electrical Engineer with over 15 years of hands-on experience in electronics design, programming, and PCB development. He specializes in microcontrollers (Arduino, ESP32, STM32, Raspberry Pi), robotics, and IoT systems. He is the founder and lead author at Electronic Clinic, dedicated to sharing practical knowledge.

Related Articles

Leave a Reply

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

Back to top button
Electronic Clinic
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.