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