1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-05-06 19:29:15 +08:00

46 lines
682 B
Go
Raw Normal View History

2013-10-22 16:45:31 -07:00
package main
import (
2013-12-03 16:11:24 -08:00
"fmt"
2013-12-03 00:48:20 -08:00
"github.com/hybridgroup/gobot"
2013-12-03 16:11:24 -08:00
"github.com/hybridgroup/gobot-firmata"
"github.com/hybridgroup/gobot-gpio"
2013-10-22 16:45:31 -07:00
)
func main() {
2013-12-03 16:11:24 -08:00
firmata := new(gobotFirmata.FirmataAdaptor)
firmata.Name = "firmata"
firmata.Port = "/dev/ttyACM0"
2013-11-13 20:47:21 -08:00
2013-12-03 16:11:24 -08:00
led := gobotGPIO.NewLed(firmata)
led.Name = "led"
led.Pin = "13"
2013-11-13 20:47:21 -08:00
connections := []interface{}{
2013-12-03 16:11:24 -08:00
firmata,
2013-11-13 20:47:21 -08:00
}
devices := []interface{}{
led,
}
work := func() {
2013-12-03 16:11:24 -08:00
gobot.Every("1s", func() {
led.Toggle()
if led.IsOn() {
fmt.Println("On")
} else {
fmt.Println("Off")
}
})
2013-11-13 20:47:21 -08:00
}
2013-12-03 16:11:24 -08:00
robot := gobot.Robot{
2013-11-13 20:47:21 -08:00
Connections: connections,
Devices: devices,
Work: work,
}
robot.Start()
2013-10-22 16:45:31 -07:00
}