mirror of
https://github.com/kidoman/embd
synced 2024-12-23 05:10:05 +01:00
29 lines
404 B
Go
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)
|
|
}
|
|
}
|