Skip to content

Instantly share code, notes, and snippets.

@matipan
Created February 22, 2017 14:23
Show Gist options
  • Save matipan/af6f0c5a4fa826984267e070d62027bd to your computer and use it in GitHub Desktop.
Save matipan/af6f0c5a4fa826984267e070d62027bd to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"log"
"time"
"gobot.io/x/gobot"
"gobot.io/x/gobot/drivers/gpio"
"gobot.io/x/gobot/platforms/firmata"
)
func main() {
firmataAdaptor := firmata.NewAdaptor("/dev/tty.usbmodem1411")
led := gpio.NewLedDriver(firmataAdaptor, "13")
var text string
work := func() {
gobot.Every(1*time.Millisecond, func() {
_, _ = fmt.Scanln(&text)
led.Toggle()
log.Println("HELLO")
})
}
robot := gobot.NewRobot("bot",
[]gobot.Connection{firmataAdaptor},
[]gobot.Device{led},
work,
)
err := robot.Start()
if err != nil {
log.Println(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment