继电器文档、gpio demo 上传
This commit is contained in:
48
demo/gpio2/main.go
Normal file
48
demo/gpio2/main.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"game-driver/internal/routes/play/card_pusher"
|
||||
"game-driver/logger"
|
||||
"github.com/warthog618/go-gpiocdev/device/rpi"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
logger.DefaultLogger()
|
||||
defer logger.Sync()
|
||||
|
||||
device, err := card_pusher.New(&card_pusher.LineGroup{
|
||||
Name: "gpiochip0",
|
||||
OutOK: rpi.GPIO6,
|
||||
Lower: rpi.GPIO13,
|
||||
Error: rpi.GPIO19,
|
||||
Empty: rpi.GPIO26,
|
||||
Push: rpi.GPIO11,
|
||||
Reset: rpi.GPIO22,
|
||||
Pull: rpi.GPIO27,
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println("打开 GPIO 设备失败:", err)
|
||||
return
|
||||
}
|
||||
defer device.Close()
|
||||
|
||||
for {
|
||||
var userInput string
|
||||
fmt.Println("按 o/p/r 发送信号")
|
||||
_, _ = fmt.Scanln(&userInput)
|
||||
|
||||
if userInput == "o" {
|
||||
device.PushCard()
|
||||
}
|
||||
if userInput == "p" {
|
||||
device.PullCard()
|
||||
}
|
||||
if userInput == "r" {
|
||||
device.Reset()
|
||||
}
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
}
|
||||
BIN
docs/继电器LH-04.zip
Executable file
BIN
docs/继电器LH-04.zip
Executable file
Binary file not shown.
Reference in New Issue
Block a user