from machine import Pin, I2C
import ssd1306
import time
print("Programa iniciou")
# ESP32 Pin assignment
i2c = I2C(0, scl=Pin(25), sda=Pin(26))
oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)
#oled.text('Boa Sorte!', 10, 10)
#oled.show()
# Push bottom
sw1 = Pin(17, Pin.IN, Pin.PULL_DOWN)
# Leds
led1 = Pin(4, Pin.OUT)
rgb2 = Pin(2, Pin.OUT)
# ==========================
# LOOP
# ==========================
while True:
# leitura do botão
if sw1.value() == 1:
print("HIGH")
led1.on()
oled.fill(0)
oled.text('Consegui!', 10, 10)
oled.show()
else:
print("LOW")
led1.off()
oled.fill(0)
oled.text('Boa Sorte!', 10, 10)
oled.show()
# pisca LED
rgb2.toggle()
time.sleep_ms(500)