2014-06-10 10:01:53 +08:00
|
|
|
# Firmata
|
2014-04-26 18:11:51 +08:00
|
|
|
|
2014-07-07 03:17:10 +08:00
|
|
|
This package provides the adaptor for microcontrollers such as Arduino that support the [Firmata](http://firmata.org/wiki/Main_Page) protocol
|
2014-04-26 18:11:51 +08:00
|
|
|
|
|
|
|
## Getting Started
|
|
|
|
|
2014-06-10 10:01:53 +08:00
|
|
|
```
|
2014-07-07 03:17:10 +08:00
|
|
|
go get github.com/hybridgroup/gobot && go install github.com/hybridgroup/gobot/platforms/firmata
|
2014-06-10 10:01:53 +08:00
|
|
|
```
|
2014-04-26 18:11:51 +08:00
|
|
|
|
|
|
|
## Example
|
|
|
|
|
|
|
|
```go
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hybridgroup/gobot"
|
2014-06-10 10:01:53 +08:00
|
|
|
"github.com/hybridgroup/gobot/platforms/firmata"
|
|
|
|
"github.com/hybridgroup/gobot/platforms/gpio"
|
|
|
|
"time"
|
2014-04-26 18:11:51 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2014-06-10 10:01:53 +08:00
|
|
|
gbot := gobot.NewGobot()
|
|
|
|
adaptor := firmata.NewFirmataAdaptor("myFirmata", "/dev/ttyACM0")
|
|
|
|
led := gpio.NewLedDriver(adaptor, "myLed", "13")
|
2014-04-26 18:11:51 +08:00
|
|
|
work := func() {
|
2014-06-10 10:01:53 +08:00
|
|
|
gobot.Every(1*time.Second, func() {
|
2014-04-26 18:11:51 +08:00
|
|
|
led.Toggle()
|
|
|
|
})
|
|
|
|
}
|
2014-06-10 10:01:53 +08:00
|
|
|
gbot.Robots = append(gbot.Robots,
|
|
|
|
gobot.NewRobot("blinkBot", []gobot.Connection{adaptor}, []gobot.Device{led}, work))
|
|
|
|
gbot.Start()
|
2014-04-26 18:11:51 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
## Hardware Support
|
|
|
|
The following firmata devices have been tested and are currently supported:
|
|
|
|
|
|
|
|
- [Arduino uno r3](http://arduino.cc/en/Main/arduinoBoardUno)
|
|
|
|
- [Teensy 3.0](http://www.pjrc.com/store/teensy3.html)
|
|
|
|
|
2014-06-10 10:01:53 +08:00
|
|
|
More devices are coming soon...
|