LED Brightness Control
Overview
A library for controlling LED brightness using PWM signals.

Supported GPIO
- Raspberry Pi 0~4
- Raspberry Pi 5
- BeagleBone Black/Green
- Jetson Nano
Commands
[INIT]
Enters initial configuration settings.
Item | Type | Description |
---|---|---|
GPIO or PWM Pin * | WRITE | Enter the GPIO number connected to the LED’s positive pin or select a PWM pin. |
* Raspberry Pi 0~4 can use any GPIO pins, while other hardware can only use designated PWM pins.
[SET_BRIGHTNESS]
Sets the brightness level.
Item | Type | Description |
---|---|---|
Brightness | WRITE | Enter the LED brightness level. (0~100%) |
Example
Objective
Increase the LED brightness by 5% every 50ms. When the LED brightness reaches above 100%, reset it back to 0%.
Parts
Part | Quantity |
---|---|
Raspberry Pi 4 * | 1 |
LED | 1 |
220Ω Resistor ** | 1 |
* Other hardware can also be used. Refer to Supported GPIO.
** For resistor value selection, refer to here.
** For resistor value selection, refer to here.
Wiring
Connect each component to the corresponding connection as listed in each row below.
Component 1 | Component 2 | GPIO |
---|---|---|
LED + Pin | | 18 * |
LED – Pin | 220Ω Resistor | GND |
* Any GPIO pins can be used.

Project Links