// Pines del LED RGB
#define RED_PIN 4
#define GREEN_PIN 5
#define BLUE_PIN 6
#define POT_PIN 26
void setup() {
// Configurar pines del LED como salida PWM
pinMode(RED_PIN, OUTPUT);
pinMode(GREEN_PIN, OUTPUT);
pinMode(BLUE_PIN, OUTPUT);
// Configurar ADC para el potenciómetro
analogReadResolution(12); // Pico W tiene 12 bits (0-4095)
}
void loop() {
// Leer valor del potenciómetro
int potValue = analogRead(POT_PIN); // 0 - 4095
// Escalar a rango PWM (0 - 255)
int brightness = map(potValue, 0, 4095, 0, 255);
// Controlar colores del LED RGB
analogWrite(RED_PIN, brightness); // Rojo proporcional
analogWrite(GREEN_PIN, 255 - brightness); // Verde inverso
analogWrite(BLUE_PIN, brightness / 2); // Azul a la mitad
delay(10);
}