Blend three PWM channels for status colors and visual feedback.
Open in compiler →/*
Roboda verified Arduino sample 0641
Feature: RGB LED
Generated for online build, classroom practice, and hardware upload testing.
*/
const byte redPin = 9;
const byte greenPin = 10;
const byte bluePin = 11;
byte hueStep = 0;
void setup() {
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop() {
analogWrite(redPin, hueStep);
analogWrite(greenPin, 255 - hueStep);
analogWrite(bluePin, (hueStep / 2) + 25);
hueStep += 5;
delay(38);
}
How it works
Practice this Arduino feature with a verified Roboda sketch.
- Read the constants at the top of the sketch.
- Wire the pins exactly as listed in the pin map.
- Upload or compile once before changing values.
- Change one value at a time and watch Serial Monitor or the output device.
Connections
| Pin | Connect to | Note |
|---|---|---|
| D9, D10, D11 | Red, green, blue LED legs through resistors | Use common-anode LEDs with inverted values if needed. |