Display Class

๐Ÿ–ฅ๏ธ 0.91โ€‘inch OLED Display (128ร—32)

๐Ÿ“Œ Description

The 0.91โ€‘inch OLED display is a small screen that can show text, numbers, and even simple graphics. It uses the SSD1306 driver chip and communicates with the microcontroller through I2C (only 4 pins: VCC, GND, SDA, SCL).

๐ŸŽฏ Use

In our projects, the OLED display is used to:

  • Show sensor readings (temperature, distance, light).
  • Display icons or small images.
  • Provide menus or status information for the robot.

๐Ÿ‘‰ Think of the OLED as the robotโ€™s mini monitor โ€” it shows what the robot wants to communicate.

ย Module parameters

Pin name Description
GND GND (Power Input Negative)
VCC VCC (Power Input Cathode)
SCL Clock signal communication pin
SDA Bidirectional data communication pins
  • Supply voltage: 3.3V/5V
  • Connection: PH2.0 terminal wire
  • Installation method: four-screw fixation

๐Ÿ–ฅ๏ธ Code Explanation

import machine
import oled128x64
from expression_picture import Heart

# Configure I2C communication (pins 26 = SCL, 5 = SDA)
i2c_extend = machine.SoftI2C(scl = machine.Pin(26), sda = machine.Pin(5), freq = 100000)

# Initialize OLED with SSD1306 driver, address 0x3c
oled = oled128x64.OLED(i2c_extend, address=0x3c, font_address=0x3A0000, types=0)

# Display a heart image at position (0,0), size 1
oled.image(Heart, x = 0, y = 0, size = 1)

Step by Step

  1. import machine, oled128x64 โ†’ Tools for pins and OLED control.
  2. from expression_picture import Heart โ†’ Imports a predefined heart image.
  3. i2c_extend = machine.SoftI2C(...) โ†’ Sets up I2C communication using pins 26 (SCL) and 5 (SDA).
  4. oled = oled128x64.OLED(...) โ†’ Initializes the OLED display with SSD1306 driver at address 0x3c.
  5. oled.image(Heart, x=0, y=0, size=1) โ†’ Draws the heart image at the topโ€‘left corner of the screen.

๐Ÿ‘‰ Together, this program makes the OLED show a heart icon.


โœ… Conclusion of the Test

  • If the OLED shows a heart image, the program is working correctly.
  • This test demonstrates how the robot can draw graphics on a small OLED screen.
  • Later, you can display text, sensor values, or even combine multiple icons to create menus and animations.
On this page