romu-rgb-led-pwm.ino
Demonstrates control of red, green, and blue channels of the RGB LED to create color gradients.
The RGB LED is integrated. Exact GPIO pins must be checked on the Romu card schematic. This code uses standard Arduino analogWrite API. For finer control, use RP2354A PWM registers.
romu-rgb-led-pwm.ino
#include <Arduino.h>
#include "hardware/pwm.h"
// Supposons que la LED RGB est câblée sur les GPIO 22, 23, 24 (À VÉRIFIER selon révision)
#define LED_R 22
#define LED_G 23
#define LED_B 24
void setup() {
// Configuration PWM simple avec analogWrite (si supporté par le core)
// Sinon, utiliser hardware/pwm.h pour un contrôle précis
pinMode(LED_R, OUTPUT);
pinMode(LED_G, OUTPUT);
pinMode(LED_B, OUTPUT);
// Fréquence PWM
analogWriteFreq(5000);
analogWriteRange(255);
}
void loop() {
// Cycle de couleurs
for (int i = 0; i < 256; i++) {
analogWrite(LED_R, i);
analogWrite(LED_G, 255 - i);
analogWrite(LED_B, 128);
delay(5);
}
for (int i = 255; i >= 0; i--) {
analogWrite(LED_R, i);
analogWrite(LED_G, 255 - i);
analogWrite(LED_B, 128);
delay(5);
}
}