mirror of
https://github.com/kidoman/embd
synced 2025-07-03 03:47:33 +02:00
gpio library for rpi
This commit is contained in:
parent
283e8eb140
commit
b7096cfe6c
6 changed files with 480 additions and 0 deletions
33
samples/gpio.go
Normal file
33
samples/gpio.go
Normal file
|
@ -0,0 +1,33 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/kidoman/embd/gpio"
|
||||
)
|
||||
|
||||
func main() {
|
||||
io := gpio.New()
|
||||
defer io.Close()
|
||||
|
||||
pin, err := io.Pin("MOSI")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if err := pin.Output(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := pin.ActiveLow(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := pin.Low(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
if err := pin.Input(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue