mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-07-26 10:38:41 +00:00
23 lines
401 B
Go
23 lines
401 B
Go
// Connects to an MMA8653 I2C accelerometer.
|
|
package main
|
|
|
|
import (
|
|
"machine"
|
|
"time"
|
|
|
|
"github.com/tinygo-org/drivers/mma8653"
|
|
)
|
|
|
|
func main() {
|
|
machine.I2C0.Configure(machine.I2CConfig{})
|
|
|
|
accel := mma8653.New(machine.I2C0)
|
|
accel.Configure(mma8653.DataRate200Hz, mma8653.Sensitivity2G)
|
|
|
|
for {
|
|
x, y, z, _ := accel.ReadAcceleration()
|
|
println(x, y, z)
|
|
time.Sleep(time.Millisecond * 100)
|
|
}
|
|
}
|