1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-27 13:48:56 +08:00
hybridgroup.gobot/examples/particle_function.go

32 lines
503 B
Go
Raw Normal View History

package main
import (
"fmt"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/particle"
)
func main() {
gbot := gobot.NewMaster()
core := particle.NewAdaptor("DEVICE_ID", "ACCESS_TOKEN")
work := func() {
if result, err := core.Function("brew", "202,230"); err != nil {
fmt.Println(err)
} else {
fmt.Println("result from \"brew\":", result)
}
}
robot := gobot.NewRobot("spark",
[]gobot.Connection{core},
work,
)
gbot.AddRobot(robot)
gbot.Start()
}