2013-10-23 07:45:31 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2013-12-03 16:48:20 +08:00
|
|
|
"github.com/hybridgroup/gobot"
|
2013-12-04 08:11:24 +08:00
|
|
|
"github.com/hybridgroup/gobot-firmata"
|
|
|
|
"github.com/hybridgroup/gobot-gpio"
|
2013-10-23 07:45:31 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
2013-12-04 08:11:24 +08:00
|
|
|
firmata := new(gobotFirmata.FirmataAdaptor)
|
|
|
|
firmata.Name = "firmata"
|
|
|
|
firmata.Port = "/dev/ttyACM0"
|
2013-11-14 12:47:21 +08:00
|
|
|
|
2013-12-04 08:11:24 +08:00
|
|
|
led := gobotGPIO.NewLed(firmata)
|
|
|
|
led.Name = "led"
|
|
|
|
led.Pin = "13"
|
2013-11-14 12:47:21 +08:00
|
|
|
|
|
|
|
work := func() {
|
2013-12-04 08:11:24 +08:00
|
|
|
gobot.Every("1s", func() {
|
|
|
|
led.Toggle()
|
|
|
|
})
|
2013-11-14 12:47:21 +08:00
|
|
|
}
|
|
|
|
|
2013-12-04 08:11:24 +08:00
|
|
|
robot := gobot.Robot{
|
2013-12-31 05:56:16 +08:00
|
|
|
Connections: []gobot.Connection{firmata},
|
|
|
|
Devices: []gobot.Device{led},
|
2013-11-14 12:47:21 +08:00
|
|
|
Work: work,
|
|
|
|
}
|
|
|
|
|
|
|
|
robot.Start()
|
2013-10-23 07:45:31 +08:00
|
|
|
}
|