Embedded_game/002_B_Car/7.I2C总线(OLED显示屏)/main.py
2025-01-02 12:48:11 +08:00

24 lines
676 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'''
实验名称I2C总线OLED显示屏
版本v1.0
日期2019.12
作者01Studio
实验内容学习使用MicroPython的I2C总线通讯编程和OLED显示屏的使用。
'''
from machine import I2C
from ssd1306k import SSD1306
#定义I2C接口和OLED对象
i2c = I2C(I2C.I2C0, mode=I2C.MODE_MASTER,scl=27, sda=28)
oled = SSD1306(i2c, addr=0x3c)
#清屏,0x00(白屏)0xff(黑屏)
oled.fill(0)
#显示字符。参数格式为str,x,y,其中x范围是0-127y范围是0-7共8行
oled.text("Hello World!", 0, 0) #写入第 0 行内容
oled.text("MicroPython", 0, 2) #写入第 2 行内容
oled.text("By 01Studio", 0, 5) #写入第 5 行内容