Initial commit
This commit is contained in:
25
relay.go
Normal file
25
relay.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
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()
|
||||
}
|
||||
Reference in New Issue
Block a user