This software can be used to drive an analog RGB LED strip using a raspberry pi
and Adafruit's [16-channel 12-bit PWM/Servo Driver - PCA9685](https://raw2.github.com/apexskier/rgbLED/master/LED_Strip_bb.png):
## The Circuit
Here's the basic idea:
- Hook up the pi to the PCA9685 breakout board using the I2C connections.
- Connect the pi's 3.3V output to VCC on the PCA9685 breakout board. Leave V+
floating.
- Follow this tutorial for the RGB LED strips:
http://learn.adafruit.com/rgb-led-strips/usage
- I used N-channel MOSFETs - three of them, one for each channel
- Connect the +12V from the LED strip to an external power supply (do NOT
use your pi for this!)
- Connect the ground side of the power supply to the pi ground
- Instead of using the PWM outputs from the arduino, we'll use the PWM
outputs from the PCA9685.
- Connect up the PWM output 0 to the MOSFET with the red wire from the
LED strip. Output 1 goes to green, output 2 goes to blue.

## Dependencies
- [WiringPi2 Python](https://github.com/WiringPi/WiringPi2-Python)
## Usage
This program is designed to be included as a python module, but also has some
command line options. It, or any python code importing it, must be run as root
(sudo), because of the I2C interface.
### CLI Options
- `-c [hex color]` - Sets the led strip to the color specified.
- `-t` - Runs a test of a couple things. Use as a demo.
- `-o` - Turn the led strip off after other actions.
### As a module
```
from rgbDriver import RGBDriver
rgb_driver = RGBDriver()
```
Methods in the module use tuples to describe rgb colors: `(red_value,
green_value, blue_value)`. Each color value can range between 0 and 4095, due
to the PWM driver's 12 bit resolution. The `convert_eight_to_twelve_bit()`
method can convert a standard 0 to 255 color value to this scale.
To describe a color you can use the string representation of a hex color code
and the method `hex_to_rgb()` to convert it or `set_hex_color()` and
`to_hex_color()` to use it directly.
The driver keeps a property `current_color` that stores the led strip's current
color (in theory). This is used internally to smoothly transition from one
color to another.
Two types of color setting methods exist. `to_...` will transition a color
change over a set time. The last argument of any `to_...` method is that
transition time in milliseconds (default 300ms). `set_...` will set a color
immediately.
Currently supported methods are:
- `to_rgb(rgb, fade=DEFAULT)`, `set_rgb(rgb)`
- `to_rand(r_range=(0, 4095), g_range=(0, 4095), b_range=(0, 4095), fade=DEFAULT)`, `set_rand(r_range=(0, 4095), g_range=(0, 4095), b_range=(0, 4095))`
- `to_hex_color(color, fade=DEFAULT)`, `set_hex_color(color)`
## TODO
- I've got a basic single color led strip and an extra N-channel MOSFET that I
want to control.
- Set current_color var after setting up pwm.
Metadata
Release files for ledDriver 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ledDriver-1.0.tar.gz | 5.5 kB | Without provenance | Details for ledDriver-1.0.tar.gz |
Release files / ledDriver-1.0.tar.gz
| Download URL | ledDriver-1.0.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a0ccef0fd51f5154d64730c72ef75c0b8d414e77f505046536ef1c9a81bad19c
|
|
BLAKE2b-256 checksum How to use checksums |
9b0c8ff29ee8f2120b36ff6fa3b031736984e2470c72d191cbdac6ce9df2fae7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for ledDriver 1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.