Example Code for Mango-Pi-I2C OLED
This article provides a comprehensive guide on connecting an OLED screen to a Mango-Pi board and programming it using Python. It includes step-by-step instructions, example code, and commands to verify success, allowing users to display text and graphics on the screen.
Requirements
- Mango-Pi board with firmware burned ×1
- OLED Screen

Connect the OLED screen to Mango-Pi
Connect VCC, GND, SCL, and SDA to the corresponding positions on the Mango-Pi board.
| Screen Pin | Mango-Pi Pin |
|---|---|
| VCC | 3V3 |
| GND | GND |
| SCL | SCL |
| SDA | SDA |
Write Script
import time
from pinpong.board import Board
from pinpong.libs.dfrobot_ssd1306 import SSD1306_I2C #Import ssd1306 library
Board("F1C").begin()
oled=SSD1306_I2C(width=128, height=64, bus_num=0) #Initializes the screen, transmits in the numbers of screen pixels
while True:
oled.fill(1) #fully filled display
oled.show() #Display is valid
print("1")
time.sleep(1)
oled.fill(0) #turn off fully filled, clear the screen
oled.show() #Display is valid
print("0")
time.sleep(1)
oled.text(0) #Display numbers
oled.text("Hello PinPong",8,8) #Display texts at specified location
oled.show() #Display is valid
time.sleep(2)
Check the result
Use the following command to verify if it succeeded.
python oled.py


Was this article helpful?
