from machine import ADC,Pin,PWM
import time
import tm1637
from tm1637 import TM1637
adc = ADC(Pin(2))
display = TM1637(clk = Pin(14), dio = Pin(12))
parlante = PWM(Pin(33), freq = 440, duty_u16 = 32768)
parlante.duty(0)
estado = 0
while True:
time.sleep_ms(100)
val = adc.read()
display.number(val)
if estado == 0 and val>3500:
parlante.duty(50)
estado = 1
elif estado == 1 and val < 1500 :
parlante.duty(0)
estado = 0