from machine import Pin, ADC
from time import sleep
ledR = Pin(4, Pin.OUT)
ledY = Pin(0, Pin.OUT)
ledG = Pin(2, Pin.OUT)
adc = ADC(34)
last_val = 0
while True:
val = adc.read()
if val != last_val:
print(val)
sleep(1)
if val < 200:
print("Low sound Detected")
ledR.off()
ledY.off()
ledG.off()
elif val >= 200 and val < 1000:
print("Moderate Sound detected")
ledR.off()
ledY.off()
ledG.on()
elif val >= 1000 and val < 3000:
print("High Sound detected")
ledR.off()
ledY.on()
ledG.off()
else:
print("Extremely High sound detected")
ledR.on()
ledY.off()
ledG.off()Loading
esp32-devkit-c-v4
esp32-devkit-c-v4