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

32 lines
607 B
Go
Raw Normal View History

package main
import (
"fmt"
"github.com/hybridgroup/gobot"
2014-04-27 19:56:18 -07:00
"github.com/hybridgroup/gobot/firmata"
"github.com/hybridgroup/gobot/i2c"
)
func main() {
2014-04-27 19:56:18 -07:00
firmataAdaptor := firmata.NewFirmataAdaptor()
firmataAdaptor.Name = "firmata"
firmataAdaptor.Port = "/dev/ttyACM0"
2014-04-27 19:56:18 -07:00
hmc6352 := i2c.NewHMC6352Driver(firmataAdaptor)
hmc6352.Name = "hmc6352"
work := func() {
gobot.Every("0.1s", func() {
fmt.Println("Heading", hmc6352.Heading)
})
}
robot := gobot.Robot{
2014-04-27 19:56:18 -07:00
Connections: []gobot.Connection{firmataAdaptor},
Devices: []gobot.Device{hmc6352},
Work: work,
}
robot.Start()
}