<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[LED strip control from a Raspberry Pi]]></title><description><![CDATA[<p dir="auto">I made <a href="https://youtu.be/w910GOYt-Ok" rel="nofollow ugc">this video</a> to demo this.</p>
<p dir="auto">You can use <a href="http://learn.makeblock.com/en/led-rgb-strip-addressable-sealed-0-5m1m/" rel="nofollow ugc">this strip</a>, or any similar 5V addressable LED strip.</p>
<p dir="auto">To prepare the Raspberry Pi with the OS, the TRIGGERcmd agent, and connection to your wifi, I recommend the <a href="https://www.triggercmd.com/forum/topic/606/windows-script-to-prep-sd-card-for-raspberry-pi-with-triggercmd-agent">setup.bat script</a> that makes that process a snap.</p>
<p dir="auto">I used a $10 Raspberry Pi Zero W, but any Pi should work.</p>
<p dir="auto">Run these commands to install pre-reqs:</p>
<pre><code>sudo su -
apt install python3-pip
pip3 install rpi_ws281x
</code></pre>
<p dir="auto">Contents of <a href="http://green.py" rel="nofollow ugc">green.py</a>:</p>
<pre><code>import sys
from rpi_ws281x import *

if len(sys.argv) &gt; 1:
    if sys.argv[1] == "white":
        color = Color(255,255,255)
        print("white")
    elif sys.argv[1] == "green":
        print("green")
        color = Color(0,255,0)
    elif sys.argv[1] == "red":
        color = Color(255,0,0)
        print("red")
    elif sys.argv[1] == "blue":
        color = Color(0,0,255)
        print("blue")
    elif sys.argv[1] == "off":
        color = Color(0,0,0)
        print("off")
    else:
        color = Color(255,255,255) # white
        print("white")
else:
    color = Color(255,255,255) # white

# 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

strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ,LED_DMA,LED_INVERT,LED_BRIGHTNESS,LED_CHANNEL)
strip.begin()

for x in range(0,LED_COUNT):
    strip.setPixelColor(x,color)

strip.show()
</code></pre>
<p dir="auto">0,255,0 is green, 255,0,0 is red, and 0,0,255 is blue.</p>
<p dir="auto">commands.json entries:</p>
<pre><code>    {"trigger":"Lights","command":"python3 \/root\/leds.py","ground":"background","voice":"lights","allowParams": "true"},
    {"trigger":"White","command":"python3 \/root\/leds.py white","ground":"background","voice":"white","allowParams": "false"},
    {"trigger":"Green","command":"python3 \/root\/leds.py green","ground":"background","voice":"green","allowParams": "false"},
    {"trigger":"Blue","command":"python3 \/root\/leds.py blue","ground":"background","voice":"blue","allowParams": "false"},
    {"trigger":"Red","command":"python3 \/root\/leds.py red","ground":"background","voice":"red","allowParams": "false"},
    {"trigger":"Off","command":"python3 \/root\/leds.py off","ground":"background","voice":"off","allowParams": "false"}
</code></pre>
<p dir="auto">This picture shows how to wire it.  Red is 5V, Grey is ground, and White is signal (middle wire on the LED strip).</p>
<p dir="auto"><img src="https://triggercmdagents.s3.amazonaws.com/raspberrypi/pi0wiring.jpg" alt="Raspberry Pi Zero LED strip wiring" class=" img-fluid img-markdown" /></p>
]]></description><link>https://www.triggercmd.com/forum/topic/636/led-strip-control-from-a-raspberry-pi</link><generator>RSS for Node</generator><lastBuildDate>Mon, 10 Aug 2026 13:55:59 GMT</lastBuildDate><atom:link href="https://www.triggercmd.com/forum/topic/636.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 11 Mar 2020 15:44:05 GMT</pubDate><ttl>60</ttl></channel></rss>