Skip to content

Driver allowing to control a LED from GPIO pins

License

Notifications You must be signed in to change notification settings

raspberrypi-go-drivers/led

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LED

Go Reference golangci-lint Go Report Card License: MIT

This drivers allows interact with a LED connected to a GPIO pin

Documentation

For full documentation, please visit Go Reference

Quick start

import (
	"fmt"
	"time"

	"github.com/raspberrypi-go-drivers/led"
	"github.com/stianeikeland/go-rpio/v4"
)

func main() {
	err := rpio.Open()
	if err != nil {
		os.Exit(1)
	}
	defer rpio.Close()

	l1 := led.NewLED(18)
	for {
		l1.Toggle()
		time.Sleep(1 * time.Second)
		state, _ := l1.GetState()
		fmt.Println(state)
	}
}

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