gobot.io/x/gobot@v1.16.0/examples/leap_motion.go (about) 1 // +build example 2 // 3 // Do not build by default. 4 5 package main 6 7 import ( 8 "fmt" 9 10 "gobot.io/x/gobot" 11 "gobot.io/x/gobot/platforms/leap" 12 ) 13 14 func main() { 15 leapMotionAdaptor := leap.NewAdaptor("127.0.0.1:6437") 16 l := leap.NewDriver(leapMotionAdaptor) 17 18 work := func() { 19 l.On(leap.MessageEvent, func(data interface{}) { 20 fmt.Println(data.(leap.Frame)) 21 }) 22 } 23 24 robot := gobot.NewRobot("leapBot", 25 []gobot.Connection{leapMotionAdaptor}, 26 []gobot.Device{l}, 27 work, 28 ) 29 30 robot.Start() 31 }