from machine import Pin, I2C
import ssd1306
import monk_rotary
import time
MonkRotatryLeft = monk_rotary.MonkRotatary(clk_pin=35, dt_pin=23)
def write_led():
# Define the I2C pins for the ESP32
# Common pins are GPIO 22 for SCL and GPIO 21 for SDA
i2c = I2C(scl=Pin(22), sda=Pin(21), freq=100000)
# Set the OLED screen width and height
oled_width = 128
oled_height = 64
# Create an SSD1306 I2C object
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)
# Clear the display buffer
oled.fill(0)
# Write text to the display buffer
oled.text('Hello, World!', 0, 0)
oled.text('MicroPython on', 0, 10)
oled.text('ESP32', 0, 20)
oled.text('Example Code', 0, 30)
# Display the content from the buffer onto the screen
oled.show()
# Add a short delay to keep the message visible
time.sleep(5)
# Clear the screen and show a new message
oled.fill(0)
oled.text('New message after delay', 0, 0)
oled.show()