respiration.ino
The GIGA's PWM goes up to 16 bits: the breathing ramp becomes perfectly smooth, without the 8-bit "staircase". Frequency is set per pin, out of the audible band.
Hardware required
An Arduino GIGA R1 WiFi (STM32H747, 1DX radio module: Wi-Fi b/g/n + BLE, u.FL antenna included), powered over USB-C. 1 LED + 330 Ω resistor on D3.
Wiring
LED anode on D3 through 330 Ω to GND. Pick a PWM pin (marked ~): D3 qualifies.
How it works
analogWriteResolution raises the channel resolution; the loop increments a float setpoint to smooth the ramp despite the hardware step. 19.5 kHz sidesteps driver whine. In the Arduino IDE, « Arduino Zephyr-based Boards » platform, « Arduino Giga R1 » board; fit the u.FL antenna before using the radio, then Upload.
Going further
Two channels to mix two LEDs (additive tint mixing), or a power dimmer on a MOSFET.
respiration.ino
// Respiration sur D3 — analogWrite 16 bits sur la GIGA.
const int LED = D3;
float niveau = 0;
float sens = 1.0f;
void setup() {
analogWriteResolution(16); // 0..65535
analogWriteFrequency(LED, 19531); // ~19.5 kHz : hors audible
Serial.begin(115200);
}
void loop() {
niveau += sens;
if (niveau >= 65535.0f || niveau <= 0.0f) sens = -sens;
analogWrite(LED, (uint16_t)niveau);
delayMicroseconds(200);
}