tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/examples/mpu6886/main.go (about)

     1  // Connects to an MPU6886 I2C accelerometer/gyroscope.
     2  package main
     3  
     4  import (
     5  	"machine"
     6  	"time"
     7  
     8  	"tinygo.org/x/drivers/mpu6886"
     9  )
    10  
    11  func main() {
    12  	machine.I2C0.Configure(machine.I2CConfig{})
    13  
    14  	accel := mpu6886.New(machine.I2C0)
    15  	accel.Configure(mpu6886.Config{})
    16  
    17  	for {
    18  		x, y, z, _ := accel.ReadAcceleration()
    19  		println(x, y, z)
    20  		time.Sleep(time.Millisecond * 100)
    21  	}
    22  }