Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

How to program an OLED display with Arduino

By Ashutosh Bhatt March 12, 2022

Sensors are used to convert a physical quantity, such as light intensity or temperature, into an electrical one. There are several types of sensors that can easily be used with an Arduino board, which is an advantage.

For example, any analog or digital sensor easily interfaces with Arduino as the board offers both analog and digital inputs. Analog sensors collect readings over a range of values and digital sensors read if a signal is active (high or low).

Potentiometer, joystick, and temperature sensors are examples of analog sensors. IR proximity, vibration, and flame or smoke sensors are digital ones. All of these sensors can directly connect with Arduino, displaying their values on a serial monitor. Displays, such as LCD or 7-segment LED, can be used to present a sensor’s value.

The OLED — or organic light-emitting diode — is another display option and serves as an alternative to the LCD. Where an LCD is passive, the OLED is active (meaning it contains amplifiers). It’s also small, bright, and extremely lightweight, which is why it’s commonly used in hand-held or pocket-sized portable gadgets.

The OLED allows for plenty of display options, including text, digits, shapes, and images. Here we’ll learn how to display a sensor value, starting with the display basics and how to interface OLED with an Arduino board.

The OLED display used in this project is approximately 1 x 1” in dimension (typically referred to as the 1-inch display). It has a built-in display controller, the SSD1306. 

Features include: 

1. 128×64 pixels
2. High contras
3. I2C communication protocol
4. Dual color (blue and yellow)
5. No backlight required
6. Active type display

One of the advantages of this type of display is that its pixels only consume energy when they are on. This means the OLED consumes less power compared to most other displays. 

As shown in the above diagram, the display has four pins. Only two — the SDA and SCL pins — are required for interfacing. For this project, the VCC pin is given 5 Volts of power supply. 

The display works on the I2C communication protocol, a single-ended, serial communication bus, which uses only two pins here: the SDA and SCL. (This is why it’s known as TWI or the two-wire interface). 

The host microcontroller must use the I2C protocol to display the value, whether as a text message, digits, a shape (such as a circle or square), an image. It can even display basic animations. To do so with Arduino, you’ll need to use the Adafruit library. 

Simply install these two libraries from Adafruit:

  • Adafruit_ssd1306.h
  • Adafruit_GFX.h 

These two libraries provide full control of the OLED sensor display. Let’s review the circuit diagram next. 

Circuit

Circuit connections
As shown in the above diagram, the circuit is built using three components:

1. The Arduino NANO board
2. An OLED display
3. A potentiometer (POT)

  • The PT has three terminals. Connect the two end-terminals with Arduino’s +5V and GND pins. The middle pin is a slider, which connects to Arduino’s analog input pin A0.
  • The OLED has four interfacing pins: the VCC, GND, SDA, and SCL. Connect the VCC and GND pins with Arduino’s +5 V and GND pins. This provides power to the display. Next, connect the SDA and SCL pins with Arduino’s A4 (SDA) and A5 (SCL) pins for data communication.
  • The Arduino board requires a USB power supply (from a computer). The onboard, voltage-regulator chip provides a 5-V supply to the POT and OLED display. 

Circuit operation

  • The POT is given a power supply of +5 V. Depending on how far its knob is rotated, it provides 0 to 5 V analog output voltage via the center slider terminal.
  • This analog voltage output is, then, fed to Arduino’s analog input pin A0. Arduino reads the input and provides a corresponding digital output number between 0 and 1023. The digital output is showcased on the OLED display as “POT Value.”
  • Next, Arduino once again converts the digital value (of between 0 and 1023) into an analog voltage between 0 to 5 V as follows:

                                Digital value     |     Analog voltage
                                       1023                               5 V
                                          X                          X × (5 / 1023)                      

  • Arduino presents the analog voltage on the display as “voltage ip.”
  • Ultimately, the analog and digital values are displayed on the OLED.

Software
The Arduino board (ATMega328) performs the following tasks, given the below software program:

1. Reads the POT’s analog voltage input and converts it into a digital value
2. Converts the digital value into an analog voltage
3. Showcases the analog and digital values on the OLED display

This program is written in C/C++ language using the Arduino IDE software. It’s compiled and uploaded using the same software.

Code

The YouTube video link for this project:

 

You may also like:


  • Sensor value display on TFT LCD using Arduino: Part I

  • What are different types of industrial robots?

  • Arduino compatible coding 18: Synchronous serial communication using the I2C…

  • Arduino compatible coding 19: Interfacing an ADXL345 accelerometer using I2C

  • Arduino compatible coding 17: Using softwareSerial in Arduino

  • What are the different types of fingerprint scanners?

Filed Under: Electronic Projects, Sensors
Tagged With: analog, Arduino, digital, microcontroller, potentiometer, sensors
 

Next Article

← Previous Article
Next Article →

EE TECH TOOLBOX

“ee
Tech Toolbox: 5G Technology
This Tech Toolbox covers the basics of 5G technology plus a story about how engineers designed and built a prototype DSL router mostly from old cellphone parts. Download this first 5G/wired/wireless communications Tech Toolbox to learn more!

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Resistor Selection for Amplifier Layout
  • Permittivity and Permealibility in CST
  • Testing 5kW Grid Tied inverter over 200-253VAC
  • Single ended measuring ports and balanced antenna
  • Thermal modelling of repetitive power pulse

RSS Electro-Tech-Online.com Discussions

  • Can I make two inputs from one??
  • Beats Solo 4
  • Behlke swich
  • Is AI making embedded software developers more productive?
  • Simple LED Analog Clock Idea

Featured – LoRa/LoRaWan Series

  • What is the LoRaWAN network and how does it work?
  • Understanding LoRa architecture: nodes, gateways, and servers
  • Revolutionizing RF: LoRa applications and advantages
  • How to build a LoRa gateway using Raspberry Pi
  • How LoRa enables long-range communication
  • How communication works between two LoRa end-node devices

Recent Articles

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe