pinpong example oled2864

I2C OLED2864 Screen Control

Here is the Python code to control an I2C OLED2864 display:

# -*- coding: UTF-8 -*-
# Experiment effect: I2C OLED2864 screen control
# Wiring: Connect an Arduino main control board to a Windows or Linux computer, and connect the OLED2864 display screen to the I2C port SCL and SDA

import time
from pinpong.board import Board
from pinpong.libs.dfrobot_ssd1306 import SSD1306_I2C # Import the ssd1306 library

Board("uno").begin()               # Initialization, choose the board type (uno, leonardo, xugu) and port number. If the port number is not entered, automatic recognition will be performed
#Board("uno","COM36").begin()      # Initialization with specified port on Windows
#Board("uno","/dev/ttyACM0").begin() # Initialization with specified port on Linux
#Board("uno","/dev/cu.usbmodem14101").begin()   # Initialization with specified port on Mac

oled=SSD1306_I2C(width=128, height=64) # Initialize the screen, pass in the number of screen pixels

while True:
    oled.fill(1) # Fill all for display
    oled.show() # Display takes effect
    print("1")
    time.sleep(1)

    oled.fill(0) # Fill all to turn off, clear the screen
    oled.show() # Display takes effect
    print("0")
    time.sleep(1)

    oled.text("0") # Display the number
    oled.text("Hello PinPong",8,8) # Display text at the specified position
    oled.show()  # Display takes effect
    time.sleep(2)