Last updated:
0 purchases
Pi5Neo 1.0.5
Pi5Neo
Simplifying NeoPixel LED Control on Raspberry Pi 5 via SPI (GPIO 10)
Pi5Neo is a Python library designed to make controlling NeoPixel LED strips super easy and efficient on the Raspberry Pi 5 (or equivalent boards). Whether you're creating dazzling light shows, informative displays, or ambient lighting, Pi5Neo simplifies the process using the Raspberry Piβs SPI interface for high-performance communication.
π Key Features
Easy NeoPixel Control: Send commands to any NeoPixel LED strip connected to the Raspberry Pi 5βs SPI interface.
Smooth Transitions: Enjoy vibrant color transitions with rainbow effects, loading bars, blinking patterns, and more.
Optimized for Performance: Tailored for the Raspberry Pi 5, ensuring fast and reliable communication with NeoPixel strips.
Minimalistic API: A simple API lets you focus on creativity without worrying about low-level hardware details.
Flexible Configurations: Control various effects and animations by easily setting colors, durations, and brightness levels.
π Installation
You can install Pi5Neo via pip:
pip install pi5neo
Requirements
Python 3.6+
spidev (automatically installed with Pi5Neo)
Hardware
Raspberry Pi 5 (or equivalent with SPI interface)
NeoPixel LED Strip (WS281x family)
π Usage
Pi5Neo makes it straightforward to set up and control your NeoPixel strip. Here's a simple example:
from pi5neo import Pi5Neo
# Initialize the Pi5Neo class with 10 LEDs and an SPI speed of 800kHz
neo = Pi5Neo('/dev/spidev0.0', 10, 800)
# Fill the strip with a red color
neo.fill_strip(255, 0, 0)
neo.update_strip() # Commit changes to the LEDs
# Set the 5th LED to blue
neo.set_led_color(4, 0, 0, 255)
neo.update_strip()
π Examples
You can find more advanced examples in the examples directory. Hereβs a quick showcase of some cool effects you can create with Pi5Neo:
Example 1: Rainbow Cycle
from pi5neo import Pi5Neo
import time
def rainbow_cycle(neo, delay=0.1):
colors = [
(255, 0, 0), # Red
(255, 127, 0), # Orange
(255, 255, 0), # Yellow
(0, 255, 0), # Green
(0, 0, 255), # Blue
(75, 0, 130), # Indigo
(148, 0, 211) # Violet
]
for color in colors:
neo.fill_strip(*color)
neo.update_strip()
time.sleep(delay)
neo = Pi5Neo('/dev/spidev0.0', 10, 800)
rainbow_cycle(neo)
Example 2: Loading Bar Effect
from pi5neo import Pi5Neo
import time
def loading_bar(neo):
for i in range(neo.num_leds):
neo.set_led_color(i, 0, 255, 0) # Green loading bar
neo.update_strip()
time.sleep(0.2)
neo.clear_strip()
neo.update_strip()
neo = Pi5Neo('/dev/spidev0.0', 10, 800)
loading_bar(neo)
βοΈ Configuration
You can configure Pi5Neo by passing in different parameters for the number of LEDs, SPI speed, and more:
Pi5Neo('/dev/spidev0.0', num_leds=20, spi_speed_khz=1000)
/dev/spidev0.0: SPI device path
num_leds: Number of LEDs in the NeoPixel strip
spi_speed_khz: SPI speed in kHz (default 800)
π οΈ Contributing
We welcome contributions from the community! To contribute:
Fork the repo.
Create a new branch (git checkout -b my-feature).
Commit your changes (git commit -m 'Add new feature').
Push to the branch (git push origin my-feature).
Create a new Pull Request.
Feel free to open issues for bugs, questions, or feature requests.
π License
This project is licensed under the MIT License - see the LICENSE file for details.
β€οΈ Acknowledgements
Pi5Neo was inspired by various open-source projects that aim to make hardware control easier and more accessible. Special thanks to the contributors of spidev and Raspberry Pi for their amazing support!
Now, let your Raspberry Pi 5 light up the room with Pi5Neo!
π Useful Links
Pi5Neo on PyPI
Pi5Neo GitHub Repository
Raspberry Pi Official Website
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.