Skip to main content

python-pwmled PyPI version

python-pwmled controls LEDs connected to a micro controller using pulse-width modulation. It supports one-color, RGB and RGBW leds driven by GPIOs of an Raspberry Pi or a PCA9685 controller.

Installation

python-pwmled requires Python 3. It can be installed using pip:

pip install pwmled

When directly controlling the GPIOs of a Raspberry Pi using the GpioDriver(see below), the pigpio C library is required. It can be installed with the following commands:

wget abyz.co.uk/rpi/pigpio/pigpio.zip
unzip pigpio.zip
cd PIGPIO
make
sudo make install

Besides the library, the pigpiod utility is installed, which starts pigpio as daemon. The daemon must be running when using the GpioDriver.

sudo pigpiod

Usage

Configuration

python-pwmled supports several possibilities for connecting LEDs to your micro controller:

  • GPIO: LEDs can be connected directly to the GPIOs of a Raspberry Pi.
  • PCA9885: A PCA9685 can be used as I2C-bus PWM controller.
from pwmled.driver.gpio import GpioDriver
from pwmled.driver.pca9685 import Pca9685Driver

# GPIO driver, which controls pins 17, 22, 23
driver = GpioDriver([17, 22, 23])
driver = GpioDriver([17, 22, 23], freq=200)
# To control the pigpio on a other machine use the host and port parameter
driver = GpioDriver([17, 22, 23], host='other.host', port=8889)

# PCA9685 driver which controls pins 1, 2, 3
driver = Pca9685Driver([1, 2, 3])
driver = Pca9685Driver([1, 2, 3], freq=200, address=0x40)

Control

Each LED needs a separated driver, which controls the corresponding pins. The number and order of pins depends on the led type:

  • One-color: 1 pin
  • RGB: 3 pins ([R, G, B])
  • RGBW: 4 pins ([R, G, B, W])

The supported operations are shown in the following example:

from pwmled import Color
from pwmled.led import SimpleLed
from pwmled.led.rgb import RgbLed
from pwmled.led.rgbw import RgbwLed
from pwmled.driver.gpio import GpioDriver

# One-color led
driver = GpioDriver([C])
led = SimpleLed(driver)
led.on()
led.brightness = 0.5
led.transition(5, brightness=0)
led.off()

# RGB led
driver = GpioDriver([R, G, B])
led = RgbLed(driver)
led.on()
led.color = Color(255, 0, 0)
led.set(color=Color(0, 255, 0), brightness=0.5) # set two properties simultaneously
led.transition(5, color=Color(0, 0, 255), brightness=1)
led.off()

# RGBW led
driver = GpioDriver([R, G, B, W])
led = RgbwLed(driver)
# RgbwLed has same interface as RgbLed

Contributions

Pull-requests are welcome, especially for adding new drivers or led types.

License

This library is provided under MIT license.

Metadata

Release files for pwmled 1.6.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pwmled 1.6.11
File Size Uploaded Provenance Actions
pwmled-1.6.11.tar.gz 8.9 kB Without provenance Details for pwmled-1.6.11.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pwmled 1.6.11
File Interpreter ABI Platform Actions
pwmled-1.6.11-py3-none-any.whl Python 3 none any Details for pwmled-1.6.11-py3-none-any.whl

Total release size: 20.9 kB

Release files / pwmled-1.6.11.tar.gz

Download URL pwmled-1.6.11.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
634b242688613ee5b73c2dfa4d514f8116b7479578e94dfda2ca7965815d4398
BLAKE2b-256 checksum
How to use checksums
3adadd986404679b04e60be72ee5aaf2f05f42a3827068eecf689306e7e4aaf6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.11.5 Darwin/23.0.0

Release files / pwmled-1.6.11-py3-none-any.whl

Download URL pwmled-1.6.11-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aa481b60bb84cf81e8198e3ec52c938b824f96e57141bd49bca7bd9dddabf58d
BLAKE2b-256 checksum
How to use checksums
906d4a31fdb40680a88a59196aef4536277de87ecdf74a44f2f83b1905c9bef5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.11.5 Darwin/23.0.0

Security for pwmled 1.6.11

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page