mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-14 03:43:42 +00:00
examples: add example for mpu6050 (#16)
Signed-off-by: Ron Evans <ron@hybridgroup.com>
This commit is contained in:
@@ -0,0 +1,22 @@
|
|||||||
|
// Connects to an MPU6050 I2C accelerometer/gyroscope.
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"machine"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/tinygo-org/drivers/mpu6050"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
machine.I2C0.Configure(machine.I2CConfig{})
|
||||||
|
|
||||||
|
accel := mpu6050.New(machine.I2C0)
|
||||||
|
accel.Configure()
|
||||||
|
|
||||||
|
for {
|
||||||
|
x, y, z := accel.ReadAcceleration()
|
||||||
|
println(x, y, z)
|
||||||
|
time.Sleep(time.Millisecond * 100)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user