from machine import Pin,ADC,I2C
import ssd1306
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
pot = ADC(Pin(34))
led = Pin(17,Pin.OUT)
pot.atten(ADC.ATTN_11DB)
oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)
while True:
oled.fill(0)
valor = int(pot.read())
oled.text('Sensor', 0, 0)
oled.text('Capacitivo', 0, 15)
oled.text('Valor: ', 0, 30)
oled.text(str(valor), 50, 30)
if valor > 2048:
led.on()
else:
led.off()
oled.show()