This drivers allows interact with a RGB LED connected to a GPIO pin
For full documentation, please visit
package main
import (
"fmt"
"os"
"time"
"github.com/raspberrypi-go-drivers/rgbled"
"github.com/stianeikeland/go-rpio/v4"
)
func main() {
err := rpio.Open()
if err != nil {
fmt.Println("impossible to init gpio")
os.Exit(1)
}
defer rpio.Close()
rgbLED := rgbled.NewRGBLED(18, 27, 22)
// Switch on the led an set it to lime green
if err := rgbLED.SetColor("#a4eb34"); err != nil {
fmt.Println(err)
os.Exit(1)
}
time.Sleep(3 * time.Second)
// Reduce the brightness to 50%
rgbLED.SetBrightness(50)
time.Sleep(3 * time.Second)
// Switch off the LED
rgbLED.SetBrightness(0)
}
This driver has has only been tested on an Raspberry Pi Zero WH using integrated bluetooth but may work well on other Raspberry Pi having integrated Bluetooth
MIT License
Special thanks to @stianeikeland
This driver is based on his work in stianeikeland/go-rpio