2014-10-18 01:42:07 +08:00
|
|
|
/*
|
2014-10-29 05:52:59 +08:00
|
|
|
Package firmata provides the Gobot adaptor for microcontrollers that support the Firmata protocol.
|
2014-10-18 01:42:07 +08:00
|
|
|
|
|
|
|
Installing:
|
|
|
|
|
2015-01-02 23:57:13 +08:00
|
|
|
go get -d -u github.com/hybridgroup/gobot/... && go get github.com/hybridgroup/gobot/platforms/firmata
|
2014-10-18 01:42:07 +08:00
|
|
|
|
2015-01-02 23:57:13 +08:00
|
|
|
Example:
|
2014-10-18 01:42:07 +08:00
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/hybridgroup/gobot"
|
|
|
|
"github.com/hybridgroup/gobot/platforms/firmata"
|
|
|
|
"github.com/hybridgroup/gobot/platforms/gpio"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
gbot := gobot.NewGobot()
|
|
|
|
|
|
|
|
firmataAdaptor := firmata.NewFirmataAdaptor("arduino", "/dev/ttyACM0")
|
|
|
|
led := gpio.NewLedDriver(firmataAdaptor, "led", "13")
|
|
|
|
|
|
|
|
work := func() {
|
|
|
|
gobot.Every(1*time.Second, func() {
|
|
|
|
led.Toggle()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
robot := gobot.NewRobot("bot",
|
|
|
|
[]gobot.Connection{firmataAdaptor},
|
|
|
|
[]gobot.Device{led},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
|
|
|
gbot.AddRobot(robot)
|
|
|
|
|
|
|
|
gbot.Start()
|
|
|
|
}
|
|
|
|
|
|
|
|
For further information refer to firmata readme:
|
|
|
|
https://github.com/hybridgroup/gobot/blob/master/platforms/firmata/README.md
|
|
|
|
*/
|
|
|
|
package firmata
|