0.96OLED實作-micropython ssd1306模組 先將 ssd1306.py 檔和main.py放在一起才能呼叫到ssd1306模組 接線 21 SCL 22 SDA 程式碼 import ssd1306 #匯入oled模組 from machine import Pin , SoftI2C #匯入i2c相關模組和腳位模組 i2c =SoftI2C( scl = Pin ( 22 ), sda = Pin ( 21 )) #設定i2c腳位 width = 128 #oled高 height = 64 #oled寛 oled = ssd1306 . SSD1306_I2C ( width , height , i2c ) #賦予變數給設制好的ssd1306模組,並給予所須參數 #oled.text("文字", x, y, col=0/1) #x是縱軸位置 #y是橫軸位置 #col=是顏色,0-BLACK,1-WHITE oled . text ( "Hello world!" , 0 , 0 , col = 1 ) oled . text ( "ESP32 NICE!" , 0 , 10 , col = 1 ) oled . text ( "i am CTK" , 0 , 30 , col = 1 ) #oled.invert(True) #背景全顯 oled . show () #顯示於oled上
留言
張貼留言