Index

MMA7660


The MMA7660 is a 3-axis digital accelerometer.

API Reference

How To Connect

Install the package with: go get gobot.io/x/gobot

You must pass in an Adaptor that supports the i2c.Connector interface to use with this Driver.

You can use the following optional params if you wish to change the I2C Bus and I2C Address from the default values.

i2c.WithBus(int): bus to use with this driver.

i2c.WithAddress(int): address to use with this driver

// default bus/address
d := i2c.NewMMA7660Driver(adaptor)

// optional bus/address
d := i2c.NewMMA7660Driver(adaptor,
                          i2c.WithBus(0),
                          i2c.WithAddress(0x34))

How To Use

Example using the MMA7660

package main

import (
        "fmt"
        "time"

        "gobot.io/x/gobot"
        "gobot.io/x/gobot/drivers/i2c"
        "gobot.io/x/gobot/platforms/firmata"
)

func main() {
        firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
        mma7660 := i2c.NewMMA7660Driver(firmataAdaptor)

        work := func() {
                gobot.Every(500*time.Millisecond, func() {
                        if x, y, z, err := mma7660.XYZ(); err == nil {
                                fmt.Println(x, y, z)
                                fmt.Println(mma7660.Acceleration(x, y, z))
                        } else {
                                fmt.Println(err)
                        }
                })
        }

        robot := gobot.NewRobot("mma76602Bot",
                []gobot.Connection{firmataAdaptor},
                []gobot.Device{mma7660},
                work,
        )

        robot.Start()
}

Compatibility