2014-04-26 03:11:51 -07:00
|
|
|
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"
|
2014-04-26 03:11:51 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2014-04-27 19:56:18 -07:00
|
|
|
firmataAdaptor := firmata.NewFirmataAdaptor()
|
|
|
|
firmataAdaptor.Name = "firmata"
|
|
|
|
firmataAdaptor.Port = "/dev/ttyACM0"
|
2014-04-26 03:11:51 -07:00
|
|
|
|
2014-04-27 19:56:18 -07:00
|
|
|
hmc6352 := i2c.NewHMC6352Driver(firmataAdaptor)
|
2014-04-26 03:11:51 -07:00
|
|
|
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},
|
2014-04-26 03:11:51 -07:00
|
|
|
Devices: []gobot.Device{hmc6352},
|
|
|
|
Work: work,
|
|
|
|
}
|
|
|
|
|
|
|
|
robot.Start()
|
|
|
|
}
|