from machine import ADC, Pin, I2C
from utime import sleep
import ssd1306
# ADC setup
adc = ADC(Pin(34))
adc.atten(ADC.ATTN_11DB)
# ESP32 Pin assignment
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)
while True:
reading = adc.read()
# Clear display
oled.fill(0)
adc_str = f'Pot Value: {reading:4}'
oled.text(adc_str, 0, 0)
oled.show()
sleep(0.1)