gobot.io/x/gobot@v1.16.0/examples/microbit_led.go (about) 1 // +build example 2 // 3 // Do not build by default. 4 5 /* 6 How to setup 7 You must be using a BBC Microbit microcontroller that has 8 been flashed with the firmware from @sandeepmistry 9 10 More info: 11 https://gobot.io/documentation/platforms/microbit/#how-to-install 12 13 This example uses the Microbit's built-in LED matrix. 14 You run the Go program on your computer and communicate 15 wirelessly with the Microbit. 16 17 How to run 18 Pass the Bluetooth name or address as first param: 19 20 go run examples/microbit_led.go "BBC micro:bit [yowza]" 21 22 NOTE: sudo is required to use BLE in Linux 23 */ 24 25 package main 26 27 import ( 28 "os" 29 "time" 30 31 "gobot.io/x/gobot" 32 "gobot.io/x/gobot/platforms/ble" 33 "gobot.io/x/gobot/platforms/microbit" 34 ) 35 36 func main() { 37 bleAdaptor := ble.NewClientAdaptor(os.Args[1]) 38 ubit := microbit.NewLEDDriver(bleAdaptor) 39 40 work := func() { 41 ubit.Blank() 42 gobot.After(1*time.Second, func() { 43 ubit.WriteText("Hello") 44 }) 45 gobot.After(7*time.Second, func() { 46 ubit.Smile() 47 }) 48 } 49 50 robot := gobot.NewRobot("blinkBot", 51 []gobot.Connection{bleAdaptor}, 52 []gobot.Device{ubit}, 53 work, 54 ) 55 56 robot.Start() 57 }