Leon Anavi
IT Tips && Tricks

Mobile & Embedded

Created: 05.05.2023 06:22 Last Modified: 05.05.2023 06:22 Views: 205
Keywords: Linux, NeoPixels, Python, Raspberry Pi OS, Raspbian, Raspberry Pi

How to Use Addressable RGB LED NeoPixels on Raspberry Pi Computer

This step by step tutorial demonstrates how to use Addressable RGB LED NeoPixels (WS2812B, WS2811, SK6812, etc) on a Raspberry Pi single board computer with Raspberry Pi OS Linux distribution and Python 3 script based on Adafruit CircuitPython libraries.

The following hardware has used for the demonstration:

Alternatively, you can use a breadboard with level shifter, power jack and in-line resistor between 220Ω and 470Ω on the data line for protection. Also instead of Olimex LED-ROPE-10 you can use a strip or a printed circuit board with other NeoPixel types like WS2812B, WS2812, WS2811, SK6812, etc.

Follow the steps below to setup and configure the software. Please note that sound must be disabled on Raspberry Pi OS to use PWM on GPIO18. Edit /boot/config.txt and change "dtparam=audio=on" to "dtparam=audio=off". After that reboot Raspberry Pi.

1. Install dependencies:

sudo pip3 install rpi_ws281x adafruit-circuitpython-neopixel
sudo python3 -m pip install --force-reinstall adafruit-blinka

2. Download the git repository with examples:

git clone https://github.com/AnaviTechnology/anavi-examples.git

3. Run the Python3 script:

cd anavi-examples/anavi-miracle-uhat/neopixels/
sudo python3 rainbow.py

The source code of the Python script is based on Adafruit CircuitPython and Blinka library as well as the following excellent tutorial.



  Home | About | Contact | Disclaimer | Sitemap 2009-2022 Leon Anavi. All rights reserved.