1
0
mirror of https://github.com/kidoman/embd synced 2024-12-23 05:10:05 +01:00
embd/samples/lsm303.go
2013-12-08 17:39:41 +05:30

29 lines
404 B
Go

package main
import (
"log"
"time"
"github.com/kid0m4n/go-rpi/i2c"
"github.com/kid0m4n/go-rpi/sensor/lsm303"
)
func main() {
bus, err := i2c.NewBus(1)
if err != nil {
log.Panic(err)
}
mems := lsm303.New(bus)
defer mems.Close()
for {
heading, err := mems.Heading()
if err != nil {
log.Panic(err)
}
log.Printf("Heading is %v", heading)
time.Sleep(500 * time.Millisecond)
}
}