from machine import Pin, PWM
import time
pwm0 = PWM(Pin(14), duty=0) # create PWM object from a pin
pwm0.freq(50) # get current frequency
flag=False
Led1=Pin(13, Pin.OUT)
LedInterruption=Pin(12, Pin.OUT)
Pulsador1=Pin(32, Pin.IN, Pin.PULL_DOWN)
Led1.off()
flag2=True
def AtiendeInterrupcion1(x):
global flag2
if flag2:
LedInterruption.on()
flag2=False
else:
LedInterruption.off()
flag2=True
def AtiendeInterrupcion2(x):
global flag2
if flag2:
LedInterruption.on()
flag2=False
else:
LedInterruption.off()
flag2=True
Interruption = Pin(23, Pin.IN, pull=Pin.PULL_DOWN)
Interruption.irq(trigger=Pin.IRQ_RISING, handler=AtiendeInterrupcion1)
Interruption = Pin(23, Pin.IN, pull=Pin.PULL_DOWN)
Interruption.irq(trigger=Pin.IRQ_RISING, handler=AtiendeInterrupcion2)
while(True):
for i in range(500,2500,10):
#pwm0.duty(i) # get current duty cycle, range 0-1023 (default 512, 50%)
pwm0.duty_ns(i*1000) # set pulse width in nanoseconds from 0 to 1_000_000_000/freq, (now 25%)
time.sleep_ms(100)
print(i)
for j in range(2500, 500, -10):
print(j)
#pwm0.duty(j) # get current duty cycle, range 0-1023 (default 512, 50%)
pwm0.duty_ns(j*1000) # set pulse width in nanoseconds from 0 to 1_000_000_000/freq, (now 25%)
time.sleep_ms(100)