pinpong example rgb1602

Controlling I2C RGB LCD1602 Display

Here is the Python code to control an I2C RGB LCD1602 display:

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

import time
from pinpong.board import Board
from pinpong.libs.rgb1602 import RGB1602 # Import the rgb1602 library from libs

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

lcd = RGB1602()

print("I2C RGB1602 TEST...")

lcd.set_rgb(0,50,0);       # Set RGB values
lcd.set_cursor(0,0)                 # Set the cursor to the origin
lcd.print("PinPong")       # Display "PinPong"

lcd.set_cursor(1,1)        # Set the cursor position
lcd.print(1234)            # Display a number

while True:
    time.sleep(1)
    lcd.scroll_left()           # Scroll the display