Pandabyte RGB LED Module: Digital and Analog Output Guide

by pandabyte in Circuits > Arduino

21 Views, 0 Favorites, 0 Comments

Pandabyte RGB LED Module: Digital and Analog Output Guide

rgbled.png

Pandabyte RGB LED Module is a simple actuator module used for learning digital and analog output control with microcontrollers such as Arduino compatible boards, ESP32, or Raspberry Pi Pico.

The module contains a single Red, Green, and Blue (RGB) LED that can be controlled individually to generate different colors and lighting effects.

A key feature of this module is that it supports two connection methods:

  1. Traditional 4-pin header for standard jumper-wire connections
  2. OR
  3. 4-pin Grove connector for quick plug-and-play prototyping

Important:

  1. The Grove connector supports only:
  2. RED color
  3. GREEN color
  4. The BLUE color is not available through the Grove connector.
  5. To use all three colors (RGB), use the male header pins with Dupont cables.

In this guide, you will learn:

  1. Module pin configuration
  2. Digital output control
  3. PWM brightness control
  4. RGB color mixing
  5. Circuit connections and Arduino programming examples


Supplies

item list.png

Hardware:

  1. PandaByte RGB LED Module
  2. Development Board (We will use PandaByte xC3m ESP32C3 Dev board)
  3. Grove Shield/Expansion Board
  4. Cables: Dupont, USB, and Grove

Software:

  1. Arduino IDE

Circuit Connections

rgb.png

Do the connection as per the table:

Note:

  1. Blue LED control is not available through Grove connector.
  2. Use male headers and Dupont cables for full RGB functionality.

Programming

Program 1: Turn ON Red, Green, and Blue LEDs one by one using digital output.

int redPin = 0;
int greenPin = 1;
int bluePin = 2;

void setup() {

pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);

}

void loop() {

// RED
digitalWrite(redPin, HIGH);
digitalWrite(greenPin, LOW);
digitalWrite(bluePin, LOW);
delay(1000);

// GREEN
digitalWrite(redPin, LOW);
digitalWrite(greenPin, HIGH);
digitalWrite(bluePin, LOW);
delay(1000);

// BLUE
digitalWrite(redPin, LOW);
digitalWrite(greenPin, LOW);
digitalWrite(bluePin, HIGH);
delay(1000);

}

Program 2: RGB Color Mixing Using PWM Generate multiple colors using PWM brightness control.

int redPin = 0;
int greenPin = 1;
int bluePin = 2;

void setup() {

pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);

}

void loop() {

// RED
analogWrite(redPin, 255);
analogWrite(greenPin, 0);
analogWrite(bluePin, 0);
delay(1000);

// GREEN
analogWrite(redPin, 0);
analogWrite(greenPin, 255);
analogWrite(bluePin, 0);
delay(1000);

// BLUE
analogWrite(redPin, 0);
analogWrite(greenPin, 0);
analogWrite(bluePin, 255);
delay(1000);

// YELLOW
analogWrite(redPin, 255);
analogWrite(greenPin, 255);
analogWrite(bluePin, 0);
delay(1000);

// CYAN
analogWrite(redPin, 0);
analogWrite(greenPin, 255);
analogWrite(bluePin, 255);
delay(1000);

// MAGENTA
analogWrite(redPin, 255);
analogWrite(greenPin, 0);
analogWrite(bluePin, 255);
delay(1000);

// WHITE
analogWrite(redPin, 255);
analogWrite(greenPin, 255);
analogWrite(bluePin, 255);
delay(1000);

}

Program 3: Smooth Color Fade Effect Generate smooth RGB fading effects using PWM.

int redPin = 0;
int greenPin = 1;
int bluePin = 2;

void setup() {

pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);

}

void loop() {

// Fade RED
for(int i = 0; i <= 255; i++) {

analogWrite(redPin, i);
analogWrite(greenPin, 0);
analogWrite(bluePin, 0);

delay(10);

}

// Fade GREEN
for(int i = 0; i <= 255; i++) {

analogWrite(redPin, 0);
analogWrite(greenPin, i);
analogWrite(bluePin, 0);

delay(10);

}

// Fade BLUE
for(int i = 0; i <= 255; i++) {

analogWrite(redPin, 0);
analogWrite(greenPin, 0);
analogWrite(bluePin, i);

delay(10);

}

}

Output

Program 1: Digital Output Control

  1. The RGB LED will switch between:
  2. RED
  3. GREEN
  4. BLUE

using simple ON/OFF digital control.

Program 2: RGB Color Mixing Using PWM

  1. The RGB LED will generate multiple mixed colors including:
  2. RED
  3. GREEN
  4. BLUE
  5. YELLOW
  6. CYAN
  7. MAGENTA
  8. WHITE

using PWM brightness control.

Program 3: Smooth Color Fade Effect

  1. The RGB LED brightness will gradually increase for:
  2. RED
  3. GREEN
  4. BLUE

creating smooth fading transitions.

Important Info

  1. PWM-capable GPIO pins are required for analog brightness control (Program 2 and 3).
  2. Digital output can be used for simple ON/OFF color control.
  3. The Grove connector supports only:
  4. RED
  5. GREEN
  6. The BLUE channel is unavailable through the Grove connector.
  7. For complete RGB functionality, use the male header pins with Dupont cables.
  8. Different color combinations can be generated by adjusting PWM duty cycles.