質問するログイン新規登録

Q&A

0回答

1229閲覧

GoBotでraspiからデータを取得できない問題

Hellooo

総合スコア6

Go

Go(golang)は、Googleで開発されたオープンソースのプログラミング言語です。

Raspberry Pi

Raspberry Piは、ラズベリーパイ財団が開発した、名刺サイズのLinuxコンピュータです。 学校で基本的なコンピュータ科学の教育を促進することを意図しています。

0グッド

0クリップ

投稿2017/04/10 07:35

編集2017/04/10 14:20

0

0

###前提・実現したいこと
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

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.29%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問