1
0
mirror of https://github.com/kidoman/embd synced 2024-11-11 03:58:53 +01:00
embd/samples/lsm303.go

29 lines
404 B
Go
Raw Normal View History

2013-12-07 18:41:06 +01:00
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)
}
}