Interfacing PIC12F1822 with SSD1306 OLED

This project is a simple interfacing of SSD1306 OLED display with PIC12F1822 microcontroller which has only 128 bytes of RAM. This project shows how to write texts and print numbers on the screen.
The SSD1306 OLED used in this example is configured to work in I2C (IIC) mode. So, make sure that your SSD1306 OLED display is configured to work in I2C mode, some displays need jumper placing or some soldering.  —  IIC or I2C: Inter-Integrated Circuit  —

Related Projects:
Interfacing PIC16F877A with SSD1306 OLED display
Real time clock with PIC12F1822, SSD1306 OLED and DS3231 RTC

Hardware Required:

  • PIC12F1822 microcontroller
  • SSD1306 OLED display
  • 5V source
  • Breadboard
  • Jumper wires

PIC12F1822 MCU with IIC I2C SSD1306 OLED display

Interfacing PIC12F1822 with SSD1306 OLED circuit:
The following image shows project circuit schematic diagram.

PIC12F1822 SSD1306 OLED dsiplay IIC I2C mode

(All grounded terminal are connected together)

The PIC12F1822 microcontroller has one hardware I2C module with SDA on pin RA2 (#5) and SCL on pin RA1 (#6). The SDA pin of the MCU is connected to the SDA pin of the display and the SCL pin of the MCU is connected to the SCL (SCK) pin of the display.
The reset pin of the display is connected to pin RA0 (#7) of the microcontroller.

The SSD1306 OLED display DC pin is connected to VDD which means the I2C slave address of the display is 0x7A.

In this project the PIC12F1822 microcontroller uses with its internal oscillator @ 32 MHz, MCLR pin is configured as an input pin.

Interfacing PIC12F1822 with SSD1306 OLED C code:
The C code below is for CCS C compiler, it was tested with version 5.051 and version 5.079.

Version 5.051:
Used RAM: 31%
Used ROM: 66%

Version 5.079:
Used RAM: 27%
Used ROM: 66%

To be able to compile the C code below with no error, a driver for the SSD1306 OLED display is required, its name is SSD1306.C, download link is below:
SSD1306 OLED display driver

after the download, add the driver file to project folder or CCS C compiler drivers folder.

For more details about this driver see the following post:
Interfacing PIC16F877A with SSD1306 OLED display

CCS C code:

Interfacing PIC12F1822 with SSD1306 OLED simulation:
The simulation of this project with Proteus should give a result similar to what shown in the following video where PIC16F877A microcontroller is used. Simulation file download link is below, use Proteus version 8.6 or higher to open it!
PIC12F1822 MCU + SSD1306 OLED

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.