from machine import Pin, ADC, I2C
import ssd1306
import time
# ESP32 Pin assignment
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
# OLED display configuration
oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)
oled.text('Hello, Wokwi!', 10, 10)
oled.show()
time.sleep(1)
# ADC configuration
adc = ADC(Pin(26))
adc.atten(ADC.ATTN_11DB) # Full range: 3.3v
while True:
adc_value = adc.read()
oled.fill(0) # Clear the display
oled.text('ADC Value:', 0, 10)
oled.text(str(adc_value), 0, 30)
oled.show()
time.sleep(1)