A library to control the onboard LEDs on a Raspberry Pi
Project description
RPiLEDController
This Python can be used to easily control the onboard-leds of a Raspberry Pi Currently the following RPis are supported:
- any Raspberry Pi 4
- any Raspberry Pi 5
Installation
To install the package, simply run the following command:
pip install RPiLEDController
Usage
To use the package, simply import it and create an instance of the RPiLEDController
class:
from RPiLEDController import RPiLEDController
led_controller = RPiLEDController()
At the end of your code, add the following line to release the leds:
led_controller.release()
ALWAYS USE SUDO TO RUN THE CODE
You will get this error if you don't use sudo: PermissionError: [Errno 13] Permission denied: '/sys/class/leds/led1/trigger'
Methods
The following methods are available:
act_off
Turns the green activity led off
act_on
Turns the green activity led on
act_release
Resets the trigger of the green activity led to "mmc0"
act_reserve
Sets the trigger of the green activity led to "none"
pwr_off
Turns the red power led off
pwr_on
Turns the red power led on
pwr_release
Resets the trigger of the red power led to "default-on"
pwr_reserve
Sets the trigger of the red power led to "none"
reserve
Sets the trigger of the red power led to "none" and the trigger of the green activity led to "none"
release
Resets the trigger of the red power led to "default-on" and the trigger of the green activity led to "mmc0"
Example
from RPiLEDController import RPiLEDController
led_controller = RPiLEDController()
led_controller.act_off()
led_controller.pwr_on()
led_controller.release()
This code will turn the green activity led off and the red power led on. At the end of the code, the triggers of both leds will be reset to their default values.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file RPiLEDController-0.1.6-py3-none-any.whl
.
File metadata
- Download URL: RPiLEDController-0.1.6-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5bc4a12c5b06d243db6f41f3029ab7da6d33fa1b35ef82ca9d5b6ea367d94fc9 |
|
MD5 | 062934a0bc1e8b2c5047196e8411c4b6 |
|
BLAKE2b-256 | 6a03fa70846b7389f5c2383d5e1450f52a52291d0e321c93cfae1aea1c02ae80 |