Created
February 22, 2017 14:23
-
-
Save matipan/af6f0c5a4fa826984267e070d62027bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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