from machine import Pin, I2C
from time import sleep_ms
import ssd1306
# I2C pin assignment (delete first parameter on error)
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
oled_width = 128
oled_height = 64
# create oled-display instance
oledSensor = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)
minuteCounter = 0 # initialize minute-counter
secondCounter = 0 # initialize second-counter
while True:
oledSensor.fill(0) # clear display
oledSensor.text('min: ' + str(minuteCounter), 0, 13)
oledSensor.text('sec: ' + str(secondCounter), 0, 25)
oledSensor.show()
secondCounter = secondCounter + 1;
if secondCounter == 60:
secondCounter = 0
minuteCounter = minuteCounter + 1
sleep_ms(1000); # pause for one second (1.000 milliseconds)