Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

RPiLEDController-0.1.6-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file RPiLEDController-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for RPiLEDController-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 5bc4a12c5b06d243db6f41f3029ab7da6d33fa1b35ef82ca9d5b6ea367d94fc9
MD5 062934a0bc1e8b2c5047196e8411c4b6
BLAKE2b-256 6a03fa70846b7389f5c2383d5e1450f52a52291d0e321c93cfae1aea1c02ae80

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page