from machine import Pin, I2C
from time import sleep
import ssd1306
led = Pin(17,Pin.OUT)
button = Pin(34, Pin.IN)
#Creazione dell'oggetto i2c
i2c = I2C(0)
#Inizializzazione del display
display = ssd1306.SSD1306_I2C(128, 64, i2c)
#Visualizzazione di diverse porzioni di testo sul display in diverse posizioni
display.fill(0) #fill(0) consente di effettuare un 'clear' del display scrivendo tutti i pixel a 0 (nero)
display.show()
while True:
button_state = button.value()
led.value(button_state)
if led.value() == 1:
display.fill(0)
display.text('ACCESO', 35, 25)
display.show()
else:
display.fill(0)
display.text('SPENTO', 35, 25)
display.show()
#sleep(1)