Arduino Nano 3-Color RGB LED Module: Full Spectrum Control

Complete Arduino Nano RGB LED module control on pins D2=Red, D3=Green, D4=Blue. 12 stunning patterns including rainbow cycle, traffic lights, mood lighting, color wipe, heartbeat, and 16 million color spectrum. Perfect for displays and effects.

Arduino Nano RGB 3-Color Module Master Control

Perfect wiring confirmed! D2=Red, D3=Green, D4=Blue. Common cathode RGB module with PWM fading capability. 12 professional patterns auto-cycle every 10 seconds: single colors, primaries, secondaries, rainbow sweep, breathing, traffic lights, and more!

Upload once → Watch 16 million colors automatically! All PWM pins for smooth fading.

Components (Perfect Wiring)

  • Arduino Nano
  • 3-Color RGB LED Module
  • Jumper wires (D2/D3/D4 + GND)

Your RGB Pinout Confirmed

Red: Digital Pin 2 (PWM capable)

Green: Digital Pin 3 (PWM 490Hz)

Blue: Digital Pin 4

Common: Arduino GND

Program: RGB 3-Color Module - 12 Auto-Cycling Patterns
// Arduino Nano RGB 3-Color Module - SPECTRUM MASTER
// D2=RED, D3=GREEN, D4=BLUE | 12 patterns auto-cycle

const int redPin = 2;
const int greenPin = 3;
const int bluePin = 4;
int pattern = 0;
unsigned long lastChange = 0;

void setup() {
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
  Serial.begin(9600);
  Serial.println("=== RGB 3-COLOR MODULE - 12 SPECTRUM PATTERNS ===");
  rgbOff();
}

void loop() {
  unsigned long now = millis();
  
  switch(pattern) {
    case 0: primaryColors(); break;
    case 1: secondaryColors(); break;
    case 2: rainbowCycle(); break;
    case 3: breathingWhite(); break;
    case 4: trafficLights(); break;
    case 5: colorWipe(); break;
    case 6: randomColors(); break;
    case 7: heartbeatRed(); break;
    case 8: blueGreenSweep(); break;
    case 9: fireEffect(); break;
    case 10: policeLights(); break;
    case 11: smoothSpectrum(); break;
  }
  
  if(now - lastChange > 10000) {
    pattern = (pattern + 1) % 12;
    Serial.print("Pattern #");
    Serial.println(pattern);
    rgbOff();
    delay(1000);
    lastChange = now;
  }
}

// === 12 PROFESSIONAL PATTERNS ===
void primaryColors() {
  setColor(255,0,0);   delay(1000); // Red
  setColor(0,255,0);   delay(1000); // Green
  setColor(0,0,255);   delay(1000); // Blue
}

void secondaryColors() {
  setColor(255,255,0); delay(1000); // Yellow
  setColor(0,255,255); delay(1000); // Cyan
  setColor(255,0,255); delay(1000); // Magenta
}

void rainbowCycle() {
  for(int i=0; i<256; i++) {
    int r = sin8(i * 3) / 2;
    int g = sin8((i + 85) * 3) / 2;
    int b = sin8((i + 170) * 3) / 2;
    setColor(r,g,b);
    delay(20);
  }
}

void breathingWhite() {
  for(int b=0; b<=255; b+=5) {
    setColor(b,b,b);
    delay(30);
  }
  for(int b=255; b>=0; b-=5) {
    setColor(b,b,b);
    delay(30);
  }
}

void trafficLights() {
  setColor(255,0,0);   delay(3000); // Red
  setColor(255,100,0); delay(2000); // Orange
  setColor(0,255,0);   delay(4000); // Green
}

void colorWipe() {
  for(int i=0; i<3; i++) {
    setColor(255,0,0); delay(500);
    setColor(0,255,0); delay(500);
    setColor(0,0,255); delay(500);
    rgbOff(); delay(300);
  }
}

void randomColors() {
  for(int i=0; i<12; i++) {
    setColor(random(128,256), random(128,256), random(128,256));
    delay(500);
  }
}

void heartbeatRed() {
  for(int b=0; b<=255; b+=10) { setColor(b,0,0); delay(15); }
  for(int b=255; b>=0; b-=20) { setColor(b,0,0); delay(20); }
}

void blueGreenSweep() {
  for(int b=0; b<=255; b+=5) {
    setColor(0,b,255-b);
    delay(40);
  }
}

void fireEffect() {
  for(int i=0; i<20; i++) {
    setColor(random(100,256), random(0,50), 0);
    delay(100);
  }
}

void policeLights() {
  for(int i=0; i<8; i++) {
    setColor(0,0,255); delay(150);
    rgbOff(); delay(75);
    setColor(255,0,0); delay(150);
    rgbOff(); delay(75);
  }
}

void smoothSpectrum() {
  for(int hue=0; hue<768; hue+=5) {
    int r = 0, g = 0, b = 0;
    if(hue < 256) { g = 255 - hue; b = hue; }
    else if(hue < 512) { r = hue - 256; b = 255 - (hue - 256); }
    else { r = 255 - (hue - 512); g = hue - 512; }
    setColor(r,g,b);
    delay(25);
  }
}

// === RGB CONTROL ===
void setColor(int r, int g, int b) {
  analogWrite(redPin, r);
  analogWrite(greenPin, g);
  analogWrite(bluePin, b);
}

void rgbOff() {
  analogWrite(redPin, 0);
  analogWrite(greenPin, 0);
  analogWrite(bluePin, 0);
}

UPLOAD → 12 Amazing Patterns Auto-Cycle

Single upload displays ALL colors forever! Serial shows pattern number.

12 Professional RGB Patterns

  • 0: Primary RGB
  • 1: Yellow/Cyan/Magenta
  • 2: Rainbow color wheel
  • 3: Breathing white
  • 4: Traffic light sequence
  • 5: Color wipe transitions
  • 6: Random color bursts
  • 7: Red heartbeat pulse
  • 8: Blue→Green sweep
  • 9: Fire flicker effect
  • 10: Police blue/red strobe
  • 11: Full HSV spectrum

Perfect PWM Pins

D2/D3 are PWM pins = smooth fading! D4 digital works fine.

Potentiometer Color Control

Program: Knob Controls Hue
// A0 potentiometer = full color wheel
int potPin = A0;
void loop() {
  int hue = analogRead(potPin) / 4;  // 0-1023 → 0-255
  int r = 0, g = 0, b = 0;
  if(hue < 85) { g = 255 - hue*3; b = hue*3; }
  else if(hue < 170) { r = (hue-85)*3; b = 255-(hue-85)*3; }
  else { r = 255-(hue-170)*3; g = (hue-170)*3; }
  setColor(r,g,b);
}

RGB Color Mixing Chart

  • (255,0,0) = Red
  • (0,255,0) = Green
  • (0,0,255) = Blue
  • (255,255,0) = Yellow
  • (255,0,255) = Magenta
  • (0,255,255) = Cyan
  • (255,255,255) = White

Troubleshooting Your Module

  • Only 1 color: Common pin must connect GND
  • No colors: Check D2/D3/D4 wiring
  • Dim: Module may need external 5V
  • Wrong colors: Swap R/G/B wires

Applications

  • Traffic light controller
  • Mood lighting
  • Status dashboard
  • Police/fire effects
  • Ambient decoration