Matrix - 3-Axis Digital Accelerometer
From FriendlyELEC WiKi
Contents
1 Introduction
三轴重力加速度主要功能是用作测量x\y\z方向上的速度,可利用测量到的速度计算当前角度。模块可以使用IIC或SPI进行通信。此配件搭载了一颗ADXL345芯片。ADXL345是Anolog Device公司的三轴数字重力传感器,13-bit精度,采集范围可以是+-2g,+-4g,+-8g和+-16g,通讯方式为SPI或I2C。配件采用5V供电,PCB上的电源转换芯片输出3.3V给ADXL345。
2 Features
- SPI/I2C,3.3V
- 13-bit,up to +-16g
- 2.54mm spacing pin interface
3 How To
3.1 Connection
- Connect Tiny4412 SDK (1506)
- GND: Ground
- VCC: 5V
- INT2:N/A
- INT1: N/A
- CS: 5V
- SCL: I2C SCL
- SDA: I2C SDA
- SDO: 5V for slave address
3.2 Code Sample in C Under Linux
#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 Compile and Run
git clone http://github.com/friendlyarm/fa-hardware.git cd fa-hardware cd demo cd matrix-3_axis_digital_accelerometer make
Copy your compiled bin to your board and you are ready to go.