import board
import analogio
import pwmio
import time
# Definir entradas analógicas para los potenciómetros
pot_red = analogio.AnalogIn(board.GP28)
pot_green = analogio.AnalogIn(board.GP27)
pot_blue = analogio.AnalogIn(board.GP26)
# Definir salidas PWM para los LEDs RGB (Ánodo común)
led_red = pwmio.PWMOut(board.GP1, frequency=1000)
led_green = pwmio.PWMOut(board.GP2, frequency=1000)
led_blue = pwmio.PWMOut(board.GP3, frequency=1000)
while True:
# Leer valores de los potenciómetros y mapearlos a PWM (invertir por ánodo común)
led_red.duty_cycle = 65535 - pot_red.value
red_dc = ((65535 - led_red.duty_cycle) * 100) / 65535
led_green.duty_cycle = 65535 - pot_green.value
green_dc = ((65535 - led_green.duty_cycle) * 100) / 65535
led_blue.duty_cycle = 65535 - pot_blue.value
blue_dc = ((65535 - led_blue.duty_cycle) * 100) / 65535
# Imprimir valores
print("Red DC: {:5.2f}%, Green DC: {:5.2f}%, Blue DC: {:5.2f}%".format(red_dc, green_dc, blue_dc))
time.sleep(0.15)
pico:GP0
pico:GP1
pico:GND.1
pico:GP2
pico:GP3
pico:GP4
pico:GP5
pico:GND.2
pico:GP6
pico:GP7
pico:GP8
pico:GP9
pico:GND.3
pico:GP10
pico:GP11
pico:GP12
pico:GP13
pico:GND.4
pico:GP14
pico:GP15
pico:GP16
pico:GP17
pico:GND.5
pico:GP18
pico:GP19
pico:GP20
pico:GP21
pico:GND.6
pico:GP22
pico:RUN
pico:GP26
pico:GP27
pico:GND.7
pico:GP28
pico:ADC_VREF
pico:3V3
pico:3V3_EN
pico:GND.8
pico:VSYS
pico:VBUS
rgb1:R
rgb1:COM
rgb1:G
rgb1:B
r1:1
r1:2
r2:1
r2:2
r3:1
r3:2
pot1:GND
pot1:SIG
pot1:VCC
pot2:GND
pot2:SIG
pot2:VCC
pot3:GND
pot3:SIG
pot3:VCC