Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/raspberrypi-go-drivers/rgbled
Driver allowing to control a RGB LED from GPIO pins
https://github.com/raspberrypi-go-drivers/rgbled
driver go golang raspberry-pi raspberrypi-drivers robotics
Last synced: 14 days ago
JSON representation
Driver allowing to control a RGB LED from GPIO pins
- Host: GitHub
- URL: https://github.com/raspberrypi-go-drivers/rgbled
- Owner: raspberrypi-go-drivers
- License: mit
- Created: 2020-12-18T18:07:00.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-12-18T18:32:06.000Z (about 4 years ago)
- Last Synced: 2024-11-09T08:39:46.474Z (2 months ago)
- Topics: driver, go, golang, raspberry-pi, raspberrypi-drivers, robotics
- Language: Go
- Homepage:
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RGBLED
[![Go Reference](https://pkg.go.dev/badge/github.com/raspberrypi-go-drivers/rgbled.svg)](https://pkg.go.dev/github.com/raspberrypi-go-drivers/rgbled)
![golangci-lint](https://github.com/raspberrypi-go-drivers/led/workflows/golangci-lint/badge.svg)
[![Go Report Card](https://goreportcard.com/badge/github.com/raspberrypi-go-drivers/rgbled)](https://goreportcard.com/report/github.com/raspberrypi-go-drivers/rgbled)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)This drivers allows interact with a RGB LED connected to a GPIO pin
## Documentation
For full documentation, please visit [![Go Reference](https://pkg.go.dev/badge/github.com/raspberrypi-go-drivers/rgbled.svg)](https://pkg.go.dev/github.com/raspberrypi-go-drivers/rgbled)
## Quick start
```go
package mainimport (
"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)
}
```## Raspberry Pi compatibility
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
## License
MIT License
---
Special thanks to @stianeikeland
This driver is based on his work in [stianeikeland/go-rpio](https://github.com/stianeikeland/go-rpio/)