hybridgroup.gobot/platforms/beaglebone/README.md

69 lines
1.5 KiB
Markdown
Raw Normal View History

2014-06-10 10:01:53 +08:00
# Beaglebone
2014-11-29 07:34:42 +08:00
The BeagleBone is an ARM based single board computer, with many different GPIO interfaces built in.
2014-11-29 07:34:42 +08:00
For more info about the BeagleBone platform click [here](http://beagleboard.org/Products/BeagleBone+Black).
2014-11-29 07:34:42 +08:00
## How to Install
2014-06-10 10:01:53 +08:00
```
2014-11-21 06:08:06 +08:00
go get -d -u github.com/hybridgroup/gobot/... && go install github.com/hybridgroup/gobot/platforms/beaglebone
2014-06-10 10:01:53 +08: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
2014-11-29 07:34:42 +08:00
```bash
2014-06-10 10:01:53 +08:00
$ GOARM=7 GOARCH=arm GOOS=linux go build examples/beaglebone_blink.go
```
2014-06-10 10:01:53 +08: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
2014-11-29 07:34:42 +08:00
```bash
2014-06-10 10:01:53 +08:00
$ scp beaglebone_blink root@192.168.7.2:/home/root/
$ ssh -t root@192.168.7.2 "./beaglebone_blink"
```
2014-11-29 07:34:42 +08:00
## How to Use
```go
package main
import (
2014-07-11 08:02:00 +08:00
"time"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/beaglebone"
"github.com/hybridgroup/gobot/drivers/gpio"
)
func main() {
2014-07-11 08:02:00 +08:00
gbot := gobot.NewGobot()
beagleboneAdaptor := beaglebone.NewAdaptor()
led := gpio.NewLedDriver(beagleboneAdaptor, "P9_12")
2014-07-11 08:02:00 +08:00
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
2014-07-11 08:02:00 +08:00
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{beagleboneAdaptor},
[]gobot.Device{led},
work,
)
2014-07-11 08:02:00 +08:00
gbot.AddRobot(robot)
gbot.Start()
}
2014-07-11 08:02:00 +08:00
```