from machine import Pin, ADC
import utime
# Set up gas sensor on ADC0 (GP26)
gas_sensor = ADC(26)
# Set up fan (blue LED) on GP15
fan = Pin(15, Pin.OUT)
# Optional: startup message
print("Smart Kitchen Gas Leak Detection System Started")
while True:
# Read analog gas level (0–65535)
gas_level = gas_sensor.read_u16()
print("Gas Level:", gas_level)
# Threshold for gas leak detection
if gas_level > 30000:
fan.high() # Turn on fan
print("Gas Leak Detected! Fan ON")
else:
fan.low() # Turn off fan
print("Air is Clean. Fan OFF")
utime.sleep(1)