# Demonstrate how to use the OLED display # This assumes that you've connected it as follows: # GND -> GND # VCC -> 3.3V # SCL -> D2 # SDA -> D4 from machine import Pin, I2C import ssd1306 from time import sleep # Set up the display i2c = I2C(0, scl=Pin(2), sda=Pin(4)) display = ssd1306.SSD1306_I2C(128, 64, i2c) # Loop forever while True: display.fill(0) # First clear the display with 0 (black) display.text("Value: {}".format(12), 5, 5) # Display a number (12, but could be any variable) display.show() # Write the data to the display sleep(1) # Wait for 1 second before doing it again