Matrix - 3-Axis Digital Accelerometer

From FriendlyELEC WiKi
Revision as of 07:46, 27 July 2015 by Tzs (Talk | contribs)

Jump to: navigation, search

1 介绍

3-Axis Digital Accelerometer

此配件搭载了一颗ADXL345芯片。ADXL345是Anolog Device公司的三轴数字重力传感器,13-bit精度,采集范围可以是+-2g,+-4g,+-8g和+-16g,通讯方式为SPI或I2C。配件采用5V供电,PCB上的电源转换芯片输出3.3V给ADXL345。

2 特性

  • SPI/I2C,3.3V
  • 13-bit,up to +-16g
  • 2.54mm排针接口,接线方便,通用性强

3 使用方法

3.1 连接

  • 连接到Tiny4412 SDK (1506)
GND针脚: 接地
VCC: 接5V
INT2:留空
INT1: 留空
CS: 接5V
SCL: I2C SCL
SDA: I2C SDA
SDO: 接5V,用来决定slave address

3.2 Linux下的C示例

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "libfahw-adxl34x.h"
 
int main(int argc, char ** argv)
{
    char *position = (char *) malloc(32);
    memset(position, 0, 32);
 
    if (adxl34xRead(position) > 0) {
        printf("Get position: %s", position);
    } else {
        printf("Fail to get position\n");
    }
    free(position);
    return 0;
}

3.3 编译并运行示例

git clone http://github.com/friendlyarm/fa-hardware.git
cd fa-hardware
cd demo
cd matrix-3_axis_digital_accelerometer
make

将编译生成的adxl34x通过ftp上传到开发板上运行即可测试。

4 相关资料