Skip to content

Instantly share code, notes, and snippets.

@zankich
Created May 28, 2014 20:55
Show Gist options
  • Select an option

  • Save zankich/52c8b22573935864ea3d to your computer and use it in GitHub Desktop.

Select an option

Save zankich/52c8b22573935864ea3d to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot-firmata"
"github.com/hybridgroup/gobot-gpio"
)
func main() {
firmata := new(gobotFirmata.FirmataAdaptor)
firmata.Name = "firmata"
firmata.Port = "/dev/ttyACM0"
button := gobotGPIO.NewMakeyButton(firmata)
button.Name = "button"
button.Pin = "2"
led := gobotGPIO.NewLed(firmata)
led.Name = "led"
led.Pin = "13"
work := func() {
gobot.On(button.Events["push"], func(data interface{}) {
fmt.Println("on")
led.On()
})
gobot.On(button.Events["release"], func(data interface{}) {
fmt.Println("off")
led.Off()
})
}
robot := gobot.Robot{
Connections: []gobot.Connection{firmata},
Devices: []gobot.Device{button, led},
Work: work,
}
robot.Start()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment