from machine import Pin, SoftI2C
import ssd1306
import time
i2c = SoftI2C(scl=Pin(22), sda=Pin(21)) # Initialize I2C connection
oled_width = 128
oled_height = 64
messages = [
'Hello, CAFRI MARYO DIHAK',
'Hello, TRSE',
'Hello, KELAS 3A',
]
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c) # Initialize the OLED display object
posisi_vertical = 0 # Initialize the vertical position
while True:
oled.fill(0) # Clear the previous display
for i in range(3):
oled.text(messages[i], 0, posisi_vertical + i * 10) # Display text vertically
oled.show() # Update the display
posisi_vertical += 1 # Move the text upward
if posisi_vertical > oled_height: # Reset the position if the text goes beyond the display
posisi_vertical = 0
time.sleep_ms(50) # Increase the delay for slower output