from machine import ADC, Pin
import time
# Connect AD of sensor to GP26
smoke_sensor = ADC(Pin(26)) #GP26 = ADC0
while True:
analog_value = smoke_sensor.read _u16() #0-65535
voltage = (analog_value / 65535) * 3.3 #convert to voltage
print("Analog Value:", analog_value, "Voltage:", voltage)
if analog_value > 30000: # adjust threshold based testing
print("Smoke detected!")
else:
print("Air is clean")
time.sleep(1)