Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Common Cathode RGB LED Controller with Arduino UNO

View and Edit Project In Cirkit DesignerImage of Common Cathode RGB LED Controller with Arduino UNO

Circuit Documentation

Summary

This circuit features a common cathode RGB LED controlled by an Arduino UNO. The RGB LED is connected through a series of resistors to limit the current flowing through each color channel (Red, Green, and Blue). The Arduino UNO is programmed to cycle through various colors and effects, demonstrating the capabilities of PWM (Pulse Width Modulation) to control the brightness of each LED channel.


Component List

1. RGB Light (Common Cathode)


2. Arduino UNO


3. Resistor (50 Ohms)


4. Resistor (50 Ohms)


5. Resistor (50 Ohms)


Wiring Details

RGB Light (Common Cathode)


Arduino UNO


Resistor (50 Ohms) - Red Channel


Resistor (50 Ohms) - Green Channel


Resistor (50 Ohms) - Blue Channel


Documented Code

// Common-cathode RGB LED: R=9, G=10, B=11
const int Rpin = 9;
const int Gpin = 10;
const int Bpin = 11;

void setup() {
  pinMode(Rpin, OUTPUT);
  pinMode(Gpin, OUTPUT);
  pinMode(Bpin, OUTPUT);
  // Start off
  setRGB(0,0,0);
}

void loop() {
  // Quick channel check
  setRGB(255, 0, 0); delay(500); // Red
  setRGB(0, 255, 0); delay(500); // Green
  setRGB(0, 0, 255); delay(500); // Blue

  // Basic mixes
  setRGB(255, 255, 0); delay(500); // Yellow
  setRGB(0, 255, 255); delay(500); // Cyan
  setRGB(255, 0, 255); delay(500); // Magenta
  setRGB(255, 255, 255); delay(700); // White

  // Smooth white fade up/down
  for (int i = 0; i <= 255; i++) { setRGB(i, i, i); delay(6); }
  for (int i = 255; i >= 0; i--) { setRGB(i, i, i); delay(6); }

  // Smooth rainbow-ish sweep (blend R->G->B)
  for (int i = 0; i <= 255; i++) { setRGB(255 - i, i, 0); delay(5); }   // R->G
  for (int i = 0; i <= 255; i++) { setRGB(0, 255 - i, i); delay(5); }   // G->B
  for (int i = 0; i <= 255; i++) { setRGB(i, 0, 255 - i); delay(5); }   // B->R
}

void setRGB(uint8_t r, uint8_t g, uint8_t b) {
  // Common-cathode: direct PWM
  analogWrite(Rpin, r);
  analogWrite(Gpin, g);
  analogWrite(Bpin, b);
}

This documentation provides a comprehensive overview of the circuit, detailing each component, its connections, and the code used to control the RGB LED.