2014-04-26 03:11:51 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2014-07-10 17:21:21 -07:00
|
|
|
"time"
|
|
|
|
|
2014-04-26 03:11:51 -07:00
|
|
|
"github.com/hybridgroup/gobot"
|
2014-05-22 19:22:14 -07:00
|
|
|
"github.com/hybridgroup/gobot/platforms/firmata"
|
|
|
|
"github.com/hybridgroup/gobot/platforms/i2c"
|
2014-04-26 03:11:51 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2014-05-22 19:22:14 -07:00
|
|
|
gbot := gobot.NewGobot()
|
2014-04-26 03:11:51 -07:00
|
|
|
|
2014-07-08 18:36:14 -07:00
|
|
|
firmataAdaptor := firmata.NewFirmataAdaptor("firmata", "/dev/ttyACM0")
|
2014-05-22 19:22:14 -07:00
|
|
|
hmc6352 := i2c.NewHMC6352Driver(firmataAdaptor, "hmc6352")
|
2014-04-26 03:11:51 -07:00
|
|
|
|
|
|
|
work := func() {
|
2014-06-06 18:58:04 -07:00
|
|
|
gobot.Every(100*time.Millisecond, func() {
|
2014-11-19 17:24:17 -08:00
|
|
|
heading, _ := hmc6352.Heading()
|
|
|
|
fmt.Println("Heading", heading)
|
2014-04-26 03:11:51 -07:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2014-07-08 18:36:14 -07:00
|
|
|
robot := gobot.NewRobot("hmc6352Bot",
|
|
|
|
[]gobot.Connection{firmataAdaptor},
|
|
|
|
[]gobot.Device{hmc6352},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
|
|
|
gbot.AddRobot(robot)
|
|
|
|
|
2014-05-22 19:22:14 -07:00
|
|
|
gbot.Start()
|
2014-04-26 03:11:51 -07:00
|
|
|
}
|