1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-05-02 22:17:12 +08:00
hybridgroup.gobot/examples/firmata_hmc6352.go

27 lines
608 B
Go
Raw Normal View History

package main
import (
"fmt"
"github.com/hybridgroup/gobot"
2014-05-22 19:22:14 -07:00
"github.com/hybridgroup/gobot/platforms/firmata"
"github.com/hybridgroup/gobot/platforms/i2c"
"time"
)
func main() {
2014-05-22 19:22:14 -07:00
gbot := gobot.NewGobot()
firmataAdaptor := firmata.NewFirmataAdaptor("firmata", "/dev/ttyACM0")
2014-05-22 19:22:14 -07:00
hmc6352 := i2c.NewHMC6352Driver(firmataAdaptor, "hmc6352")
work := func() {
2014-06-06 18:58:04 -07:00
gobot.Every(100*time.Millisecond, func() {
fmt.Println("Heading", hmc6352.Heading)
})
}
2014-05-22 19:22:14 -07:00
gbot.Robots = append(gbot.Robots,
gobot.NewRobot("hmc6352Bot", []gobot.Connection{firmataAdaptor}, []gobot.Device{hmc6352}, work))
gbot.Start()
}