from machine import Pin
from machine import PWM
import time
# Create a PWM object in a pin
do=261
re=277
mi=293
pwm = machine.PWM(Pin(3)) # IN RP2040 the led is in 5
while True:
pwm.duty_u16(40000) # volumenz
pwm.freq(do) # Nota
time.sleep(1) # Tiempo de nota
pwm.duty_u16(0) # Configure frequency at 5000 Hz
time.sleep(0.01) # Resceso
pwm.duty_u16(40000)
pwm.freq(re)
time.sleep(1)
pwm.duty_u16(0)
time.sleep(0.01)
pwm.duty_u16(20000)
pwm.freq(mi)
time.sleep(1)
pwm.duty_u16(0)
time.sleep(0.01)
pwm.duty_u16(20000)
pwm.freq(do)
time.sleep(1)
pwm.duty_u16(0)
time.sleep(0.01)
# by asigning a value to x you can change the duty cycle