from machine import Pin,ADC
from picozero import Speaker
from time import sleep
gas_sensor = ADC(Pin(26))
buzzer = Speaker(15)
while True:
gas_value = gas_sensor.read_u16()
voltage = (gas_value /65535)*3.3
print("Gas sensor: ",gas_value,"Voltage: ",round(voltage,2),"V")
if gas_value> 40000:
print("High Gas Concentration Dected")
buzzer.on()
else:
print("Gas Level Safe ")
buzzer.off()
sleep(1)