Exemple #1
0
func NewCompass(bus i2c.Bus) Compass {
	var comp compass

	comp.sensor = lsm303.New(bus)

	return &comp
}
Exemple #2
0
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)
	}
}