LED strip control from a Raspberry Pi

  • I made this video to demo this.

    You can use this strip, or any similar 5V addressable LED strip.

    To prepare the Raspberry Pi with the OS, the TRIGGERcmd agent, and connection to your wifi, I recommend the setup.bat script that makes that process a snap.

    I used a $10 Raspberry Pi Zero W, but any Pi should work.

    Run these commands to install pre-reqs:

    sudo su -
    apt install python3-pip
    pip3 install rpi_ws281x

    Contents of green.py:

    import sys
    from rpi_ws281x import *
    # LED strip configuration:
    LED_COUNT      = 300      # Number of LED pixels.
    LED_PIN        = 18      # GPIO pin connected to the pixels (18 uses PWM!).
    #LED_PIN        = 10      # GPIO pin connected to the pixels (10 uses SPI /dev/spidev0.0).
    LED_FREQ_HZ    = 800000  # LED signal frequency in hertz (usually 800khz)
    LED_DMA        = 10      # DMA channel to use for generating signal (try 10)
    LED_BRIGHTNESS = 255     # Set to 0 for darkest and 255 for brightest
    LED_INVERT     = False   # True to invert the signal (when using NPN transistor level shift)
    LED_CHANNEL    = 0       # set to '1' for GPIOs 13, 19, 41, 45 or 53
    for x in range(0,LED_COUNT):
    if sys.argv[1] == 'off':
        for x in range(0,LED_COUNT):

    0,255,0 is green, 255,0,0 is red, and 0,0,255 is blue.

    commands.json entries:

        {"trigger":"Green","command":"python3 \/root\/green.py","ground":"background","voice":"green","allowParams": "true"},
        {"trigger":"Blue","command":"python3 \/root\/blue.py","ground":"background","voice":"blue","allowParams": "true"},
        {"trigger":"Red","command":"python3 \/root\/red.py","ground":"background","voice":"red","allowParams": "true"},

    This picture shows how to wire it. Red is 5V, Grey is ground, and White is signal (middle wire on the LED strip).
    Raspberry Pi Zero LED strip wiring

Log in to reply