gobot.io/x/gobot@v1.16.0/examples/minidrone.go (about) 1 // +build example 2 // 3 // Do not build by default. 4 5 /* 6 How to run 7 Pass the Bluetooth name or address as first param: 8 9 go run examples/minidrone.go "Mambo_1234" 10 11 NOTE: sudo is required to use BLE in Linux 12 */ 13 14 package main 15 16 import ( 17 "os" 18 "time" 19 20 "gobot.io/x/gobot" 21 "gobot.io/x/gobot/platforms/ble" 22 "gobot.io/x/gobot/platforms/parrot/minidrone" 23 ) 24 25 func main() { 26 bleAdaptor := ble.NewClientAdaptor(os.Args[1]) 27 drone := minidrone.NewDriver(bleAdaptor) 28 29 work := func() { 30 drone.TakeOff() 31 32 gobot.After(5*time.Second, func() { 33 drone.Land() 34 }) 35 } 36 37 robot := gobot.NewRobot("minidrone", 38 []gobot.Connection{bleAdaptor}, 39 []gobot.Device{drone}, 40 work, 41 ) 42 43 robot.Start() 44 }