tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/examples/mpu9150/main.go (about) 1 // Connects to an MPU9150 I2C accelerometer/gyroscope. 2 package main 3 4 import ( 5 "machine" 6 "time" 7 8 "tinygo.org/x/drivers/mpu9150" 9 ) 10 11 func main() { 12 machine.I2C0.Configure(machine.I2CConfig{}) 13 14 accel := mpu9150.New(machine.I2C0) 15 accel.Configure() 16 17 for { 18 x, y, z := accel.ReadAcceleration(mpu9150.ACCEL_XOUT_H) 19 println(x, y, z) 20 time.Sleep(time.Millisecond * 100) 21 } 22 }