1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-24 13:48:49 +08:00

47 lines
992 B
Go
Raw Normal View History

2014-10-17 12:42:07 -05:00
/*
2014-10-28 14:52:59 -07:00
Package firmata provides the Gobot adaptor for microcontrollers that support the Firmata protocol.
2014-10-17 12:42:07 -05:00
Installing:
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
2014-10-17 12:42:07 -05:00
Example:
2014-10-17 12:42:07 -05:00
package main
import (
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/firmata"
2014-10-17 12:42:07 -05:00
)
func main() {
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
led := gpio.NewLedDriver(firmataAdaptor, "13")
2014-10-17 12:42:07 -05:00
work := func() {
gobot.Every(1*time.Second, func() {
if err := led.Toggle(); err != nil {
fmt.Println(err)
}
2014-10-17 12:42:07 -05:00
})
}
robot := gobot.NewRobot("bot",
[]gobot.Connection{firmataAdaptor},
[]gobot.Device{led},
work,
)
if err := robot.Start(); err != nil {
panic(err)
}
2014-10-17 12:42:07 -05:00
}
For further information refer to firmata readme:
https://github.com/hybridgroup/gobot/blob/release/platforms/firmata/README.md
2014-10-17 12:42:07 -05:00
*/
package firmata // import "gobot.io/x/gobot/v2/platforms/firmata"