How to Control RGBWW LED Strips with Raspberry Pi

Are you trying to control RGBWW LED Strips and don’t know where to start? This passage will show carefully how to control RGB+CCT LED Strips via Raspberry Pi. Please follow the steps below and make colorful lighting effects on your own.

1. Tools

Raspberry Pi Board

Raspberry Pi board
Raspberry Pi Board Introduction

Raspberry Pi is a small computer whose components are all put on a single board. Its core components include a central processor (CPU), graphics processor (GPU), memory (RAM), USB ports, HDMI output, an SD card slot, the operating system, GPIO (General Purpose Input/Output) pin and built-in Wi-Fi/Bluetooth.
The Raspberry Pi is primarily used for education area such as programming learning and electronics. Gradually, it becomes more affordable and accessible and is widely used in other fields such as media centers, prototyping and DIY projects including building robots, smart home devices and retro gaming consoles. Raspberry Pi has been used as a lightweight server for various applications. Its versatility and low cost make it popular among hobbyists, students, and professionals.

Power Supply

  • Input voltage: AC220V
  • Output voltage: 5V
  • Power: 400W

Usage:

  • Power Raspberry Pi and RGBWW LED Strip
  • Excellent heat dissipation
Arduino 5V LED Power Supply

Converter

converter
4-way level converter

The 4-level converter is a power electronic circuit used in high-voltage applications like HVDC transmission or large motor drives. Instead of generating just high/low voltage outputs like simpler converters, it creates four distinct voltage levels at its output terminal. The converter provides stepped, staircase-like waveform by cleverly combining multiple semiconductor switches and DC voltage sources or capacitors. The vonverter significantly reduces harmonic distortion in the output voltage, lower stress on components and improve efficiency. Thus, it provides better power supply, especially at higher power levels.

5V Pixel RGBWW LED Strip

D4 5V RGBWW 1

Parameters:

  • Type: addressable Regular LED strip
  • Voltage: 5V
  • Color: RGBWW
  • LED Qty: 180LEDs/m
  • Features: This RGBWW LED strip use SMD5050 LED and have multiple color modes for choice. It can be used as RGB or CCT tunable white LED strip. It is also feasible to light the five colors simultabeously. The waterproof grade we provide includes IP20, IP65, IP66, IP67 led strip and IP68 underwater waterproof led strip.

2. Raspberry Pi 4B Control Board and RGBWW LED Strip Wiring Diagram

Raspberry Pi RGBWW wire diagram

Note:
1. The current of the light strip is too large, please use an external power supply to power the light strip

2. The Da3.3/5V interface is the voltage output port of the control board and cannot be connected tothe power supply;

3. The control board is powered by a dedicated power supply, and the light strip is powered by DC5V.Please note that the GND is shared;

4. The wiring of RGB is the same as that of RGBW, but the program cannot be shared;

5. The more points, the lower the refresh rate;6. Note that the GPlO of Raspberry Pi 4B is 3.3V logic level, so the GPlO pin needs to be converted to alevel before connecting to the light strip signal pin (74HCT125 or MOSFET level conversion).

3. Raspberry Pi RGBWW LED Connection Diagram

Raspberry Pi RGBWW connection

Please check the diagram above. When connect the controller and RGBWW LED strip, please make sure that each wire is connected to the right PIN on both converter and the Raspberry Pi. All terminals should be securely connected. And please always disconnect the power before any adjustment.

4. Code Programming

Raspberry Pi programming
				
					#!/usr/bin/env python3
import RPi.GPIO as GPIO
from rpi_ws281x import PixelStrip, Color
import time
import math
import signal
import sys

# === hardware setup ===
# WS2812B RGB led strip
RGB_LED_COUNT = 100 # LED quantity
RGB_PIN = 18            # data PIN
RGB_BRIGHTNESS = 80     # brightness(0-255)

# white CCT LED strip(cold white CW + warm white WW)
CW_PIN = 13             # cold white PWM PIN
WW_PIN = 12             # warm white PWM PIN
CCT_FREQ = 1000         # PWM frequency(Hz)

# === formation ===
# RGB LED strip
strip = PixelStrip(RGB_LED_COUNT, RGB_PIN, brightness=RGB_BRIGHTNESS)
strip.begin()

# white CCT
GPIO.setmode(GPIO.BCM)
GPIO.setup([CW_PIN, WW_PIN], GPIO.OUT)
pwm_cw = GPIO.PWM(CW_PIN, CCT_FREQ)
pwm_ww = GPIO.PWM(WW_PIN, CCT_FREQ)
pwm_cw.start(0)
pwm_ww.start(0)

# === core effect function ===
def wheel(pos):
    """generate rainbow Color(0-255 input)"""
    pos = 255 - pos  # reverse color_direction(optional)
    if pos < 85:
        return Color(pos * 3, 255 - pos * 3, 0)
    elif pos < 170:
        pos -= 85
        return Color(255 - pos * 3, 0, pos * 3)
    else:
        pos -= 170
        return Color(0, pos * 3, 255 - pos * 3)

def flowing_rainbow_with_cct(speed_ms=30):
    """recycle running rainbow flow + dynamic color temperature"""
    step = 0
    while True:  # endless recycle
        # dynamic color temperature(2500K~6500K sine fluctuation)
        kelvin = 2500 + int(4000 * (0.5 + 0.5 * math.sin(step * 0.015)))
        set_cct(kelvin)
        
        # rainbow_flowing effect(color phase of every LED remove)
        for i in range(strip.numPixels()):
            hue = int((i * 5 + step) % 256)  # adjust 5 control wave density
            strip.setPixelColor(i, wheel(hue))
        
        strip.show()
        time.sleep(speed_ms / 1000.0)
        step += 1

def set_cct(kelvin):
    """setup color temperature(2500K-6500K)"""
    kelvin = max(2500, min(kelvin, 6500))
    if kelvin <= 4000:
        ww = 100 - (kelvin - 2500) / 15
        cw = 0
    else:
        cw = (kelvin - 4000) / 25
        ww = 0
    pwm_cw.ChangeDutyCycle(cw)
    pwm_ww.ChangeDutyCycle(ww)

# === escape safely ===
def signal_handler(sig, frame):
    print("\nclose light...")
    for i in range(strip.numPixels()):
        strip.setPixelColor(i, Color(0, 0, 0))
    strip.show()
    pwm_cw.ChangeDutyCycle(0)
    pwm_ww.ChangeDutyCycle(0)
    GPIO.cleanup()
    sys.exit(0)

signal.signal(signal.SIGINT, signal_handler)

# === main program ===
if __name__ == '__main__':
    try:
        print("addressable flowing running (Ctrl+C stop)...")
        flowing_rainbow_with_cct(speed_ms=25)  # speed adjustable
    except KeyboardInterrupt:
        signal_handler(None, None)
				
			

5. Final Video

Below is a video took by us through which you could have a clearer look at the wire connection and the normal lighting effect.

RGBWW LED strip  provide more color choices than normal LED strips. After the whole introduction, I believe you can create the lighting effects you want by using Raspberry Pi controller. 

Please contact us if you have further questions about the RGBWW LED strip and Raspberry Pi.

Feel Free To Contact Us

We will reply your email within 12 hours.

Ask For A Quote