###前提・実現したいこと
GoBotを用いてRaspberrypi3のGPIO3(PIN番号5)に接続したSB612Aからデータを取得したい
###発生している問題・エラーメッセージ
2017/04/10 16:21:44 Initializing connections...
2017/04/10 16:21:44 Initializing connection RaspberryPi ...
2017/04/10 16:21:44 Initializing devices...
2017/04/10 16:21:44 Initializing device DirectPin-1DBD7BBF ...
2017/04/10 16:21:44 Robot sensorbot initialized.
2017/04/10 16:21:44 Starting Robot sensorbot ...
2017/04/10 16:21:44 Starting connections...
2017/04/10 16:21:44 Starting connection RaspberryPi...
2017/04/10 16:21:44 Starting devices...
2017/04/10 16:21:44 Starting device DirectPin-1DBD7BBF on pin 3...
2017/04/10 16:21:44 Starting work...
と接続はできているのだが取得している値が0で別の言語書いたスクリプトで検知している動きで検知されていない問題
###該当のソースコード
main.go
1 package main 2 3 import ( 4 "fmt" 5 "gobot.io/x/gobot" 6 "gobot.io/x/gobot/drivers/gpio" 7 "gobot.io/x/gobot/platforms/raspi" 8 "time" 9 ) 10 11 const ( 12 SensorValueDetect = 1 13 SensorValueUndetect = 0 14 ) 15 16 func main() { 17 rascon := raspi.NewAdaptor() 18 first_sensor := gpio.NewDirectPinDriver(rascon, "5") 19 work := func() { 20 gobot.Every(1*time.Second, func() { 21 v, _ := first_sensor.DigitalRead() 22 if v == SensorValueDetect { 23 fmt.Println("CHECK!!!!!!") 24 fmt.Println(v) 25 } else { 26 fmt.Println(v) 27 } 28 }) 29 } 30 robot := gobot.NewRobot("sensorbot", 31 []gobot.Connection{rascon}, 32 []gobot.Device{first_sensor}, 33 work, 34 ) 35 robot.Start() 36 }
###試したこと
課題に対してアプローチしたことを記載してください
###補足情報(言語/FW/ツール等のバージョンなど)
go version go1.7.3 linux/arm
raspberry pi3 typeb
あなたの回答
tips
プレビュー