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

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