Files
hh/hhio/relay.go

26 lines
278 B
Go
Raw Normal View History

2022-09-24 16:35:03 -07:00
package hhio
2022-09-24 16:29:26 -07:00
import "github.com/stianeikeland/go-rpio/v4"
type Relay struct {
pin rpio.Pin
}
func NewRelay(pin int) *Relay {
r := &Relay{
pin: rpio.Pin(pin),
}
r.pin.Output()
return r
}
func (r *Relay) On() {
r.pin.High()
}
func (r *Relay) Off() {
r.pin.Low()
}