gobot.io/x/gobot@v1.16.0/examples/firmata_grove_sound_sensor.go (about) 1 // +build example 2 // 3 // Do not build by default. 4 5 package main 6 7 import ( 8 "fmt" 9 "os" 10 11 "gobot.io/x/gobot" 12 "gobot.io/x/gobot/drivers/aio" 13 "gobot.io/x/gobot/platforms/firmata" 14 ) 15 16 func main() { 17 board := firmata.NewAdaptor(os.Args[1]) 18 sensor := aio.NewGroveSoundSensorDriver(board, "3") 19 20 work := func() { 21 sensor.On(aio.Data, func(data interface{}) { 22 fmt.Println("sensor", data) 23 }) 24 } 25 26 robot := gobot.NewRobot("sensorBot", 27 []gobot.Connection{board}, 28 []gobot.Device{sensor}, 29 work, 30 ) 31 32 robot.Start() 33 }