1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-05-01 13:48:57 +08:00

59 lines
1.5 KiB
Markdown
Raw Normal View History

2014-06-09 19:01:53 -07:00
# Beaglebone
2014-06-09 19:01:53 -07:00
This package provides the Gobot adaptor for the [Beaglebone Black](http://beagleboard.org/Products/BeagleBone+Black/)
## Getting Started
2014-06-09 19:01:53 -07:00
## Installing
```
2014-07-06 14:17:10 -05:00
go get github.com/hybridgroup/gobot && go install github.com/hybridgroup/platforms/gobot/beaglebone
2014-06-09 19:01:53 -07:00
```
## Cross compiling for the Beaglebone Black
You must first configure your Go environment for arm linux cross compiling
```bash
$ cd $GOROOT/src
$ GOOS=linux GOARCH=arm ./make.bash --no-clean
```
Then compile your Gobot program with
```bash
2014-06-09 19:01:53 -07:00
$ GOARM=7 GOARCH=arm GOOS=linux go build examples/beaglebone_blink.go
```
2014-06-09 19:01:53 -07:00
If you are running the official Angstrom or Debian linux through the usb->ethernet connection, you can simply upload your program and execute it with
``` bash
2014-06-09 19:01:53 -07:00
$ scp beaglebone_blink root@192.168.7.2:/home/root/
$ ssh -t root@192.168.7.2 "./beaglebone_blink"
```
## Example
```go
package main
import (
"github.com/hybridgroup/gobot"
2014-06-09 19:01:53 -07:00
"github.com/hybridgroup/gobot/platforms/beaglebone"
"github.com/hybridgroup/gobot/platforms/gpio"
"time"
)
func main() {
2014-06-09 19:01:53 -07:00
gbot := gobot.NewGobot()
2014-06-09 19:01:53 -07:00
adaptor := beaglebone.NewBeagleboneAdaptor("beaglebone")
led := gpio.NewLedDriver(adaptor, "led", "P9_12")
work := func() {
2014-06-09 19:01:53 -07:00
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
2014-06-09 19:01:53 -07:00
gbot.Robots = append(gbot.Robots,
gobot.NewRobot("blinkBot", []gobot.Connection{adaptor}, []gobot.Device{led}, work))
gbot.Start()
}
2014-06-09 19:01:53 -07:00
```