hybridgroup.gobot/platforms/microbit
deadprogram 1ad0207642 microbit: simplify install instructions on microbit README
Signed-off-by: deadprogram <ron@hybridgroup.com>
2017-03-18 17:42:21 +01:00
..
LICENSE microbit: initial implementation for LEDs 2017-02-28 19:40:16 +01:00
README.md microbit: simplify install instructions on microbit README 2017-03-18 17:42:21 +01:00
accelerometer_driver.go microbit: add magnetometer driver 2017-03-18 17:09:43 +01:00
accelerometer_driver_test.go microbit: add accelerometer implementation 2017-03-01 01:23:50 +01:00
button_driver.go microbit: improve button implementation, add integrated example 2017-02-28 20:19:09 +01:00
button_driver_test.go microbit: initial implementation for built-in buttons 2017-02-28 20:03:20 +01:00
doc.go microbit: update docs 2017-03-10 12:37:32 +01:00
led_driver.go microbit: initial implementation for built-in buttons 2017-02-28 20:03:20 +01:00
led_driver_test.go microbit: initial implementation for LEDs 2017-02-28 19:40:16 +01:00
magnetometer_driver.go microbit: add magnetometer driver 2017-03-18 17:09:43 +01:00
magnetometer_driver_test.go microbit: add magnetometer driver 2017-03-18 17:09:43 +01:00
temperature_driver.go microbit: add temperature driver 2017-03-18 17:22:17 +01:00
temperature_driver_test.go microbit: add temperature driver 2017-03-18 17:22:17 +01:00

README.md

Microbit

The Microbit is a tiny computer with built-in Bluetooth LE aka Bluetooth 4.0.

How to Install

go get -d -u gobot.io/x/gobot/... && go install gobot.io/x/gobot/platforms/microbit

You must install the Microbit firmware from [@sandeepmistry] located at https://github.com/sandeepmistry/node-bbc-microbit to use the Microbit with Gobot. This firmware is based on the micro:bit template, but with a few changes.

If you have the Gort command line tool installed, you can use the following commands:

gort microbit download
gort microbit install /media/mysystem/MICROBIT

You can also follow the firmware installation instructions at https://github.com/sandeepmistry/node-bbc-microbit#flashing-microbit-firmware.

The source code for the firmware is located at https://github.com/sandeepmistry/node-bbc-microbit-firmware however you do not need this source code to install the firmware using the installation instructions.

How to Use

The Gobot platform for the Microbit includes several different drivers, each one corresponding to a different capability:

  • AccelerometerDriver
  • ButtonDriver
  • LEDDriver
  • MagnetometerDriver
  • TemperatureDriver

The following example uses the LEDDriver:

package main

import (
	"os"
	"time"

	"gobot.io/x/gobot"
	"gobot.io/x/gobot/platforms/ble"
	"gobot.io/x/gobot/platforms/microbit"
)

func main() {
	bleAdaptor := ble.NewClientAdaptor(os.Args[1])
	ubit := microbit.NewLEDDriver(bleAdaptor)

	work := func() {
		ubit.Blank()
		gobot.After(1*time.Second, func() {
			ubit.WriteText("Hello")
		})
		gobot.After(7*time.Second, func() {
			ubit.Smile()
		})
	}

	robot := gobot.NewRobot("blinkBot",
		[]gobot.Connection{bleAdaptor},
		[]gobot.Device{ubit},
		work,
	)

	robot.Start()
}

How to Connect

The Microbit is a Bluetooth LE device.

You need to know the BLE ID of the Microbit that you want to connect to.

OSX

To run any of the Gobot BLE code you must use the GODEBUG=cgocheck=0 flag in order to get around some of the issues in the CGo-based implementation.

For example:

GODEBUG=cgocheck=0 go run examples/microbit_blink.go "BBC micro:bit"

OSX uses its own Bluetooth ID system which is different from the IDs used on Linux. The code calls thru the XPC interfaces provided by OSX, so as a result does not need to run under sudo.

Ubuntu

On Linux the BLE code will need to run as a root user account. The easiest way to accomplish this is probably to use go build to build your program, and then to run the requesting executable using sudo.

For example:

go build examples/microbit_blink.go
sudo ./microbit_blink "BBC micro:bit"

Windows

Hopefully coming soon...