mpu9150: add mpu9150 driver
This commit is contained in:
fchiesadoc
2023-08-27 06:38:33 -03:00
committed by GitHub
parent 1e4545828f
commit a9b36f8bd4
6 changed files with 256 additions and 3 deletions
+22
View File
@@ -0,0 +1,22 @@
// Connects to an MPU9150 I2C accelerometer/gyroscope.
package main
import (
"machine"
"time"
"tinygo.org/x/drivers/mpu9150"
)
func main() {
machine.I2C0.Configure(machine.I2CConfig{})
accel := mpu9150.New(machine.I2C0)
accel.Configure()
for {
x, y, z := accel.ReadAcceleration(mpu9150.ACCEL_XOUT_H)
println(x, y, z)
time.Sleep(time.Millisecond * 100)
}
}