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:
|
|
|
|
|
2016-12-08 20:24:03 +08:00
|
|
|
go get -d -u gobot.io/x/gobot/... && go get gobot.io/x/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"
|
|
|
|
|
2016-12-08 20:24:03 +08:00
|
|
|
"gobot.io/x/gobot"
|
|
|
|
"gobot.io/x/gobot/drivers/gpio"
|
|
|
|
"gobot.io/x/gobot/platforms/firmata"
|
2014-10-18 01:42:07 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2016-09-26 02:49:20 +08:00
|
|
|
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
|
|
|
|
led := gpio.NewLedDriver(firmataAdaptor, "13")
|
2014-10-18 01:42:07 +08:00
|
|
|
|
|
|
|
work := func() {
|
|
|
|
gobot.Every(1*time.Second, func() {
|
|
|
|
led.Toggle()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
robot := gobot.NewRobot("bot",
|
|
|
|
[]gobot.Connection{firmataAdaptor},
|
|
|
|
[]gobot.Device{led},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
2016-10-19 03:37:10 +08:00
|
|
|
robot.Start()
|
2014-10-18 01:42:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
For further information refer to firmata readme:
|
2016-12-21 17:51:54 +08:00
|
|
|
https://github.com/hybridgroup/gobot/blob/master/platforms/firmata/README.md
|
2014-10-18 01:42:07 +08:00
|
|
|
*/
|
2016-12-08 20:24:03 +08:00
|
|
|
package firmata // import "gobot.io/x/gobot/platforms/firmata"
|