简介
ADXL335是一款小尺寸、薄型、低功耗、完整的三轴加速度计,提供经过信号调理的电压输出,该产品的满量程加速度测量方位为+3g(最小值),可以测量倾斜检测应用中的静态重力加速度,以及运动、冲击或振动造成的动态加速度,可用于游戏系统、磁盘保护、图像稳定等场合。用户可以通过XOUT、YOUT和ZOUT引脚上的电容CX、CY和CZ选择该加速度计的带宽。我们可以根据实际应用选择合适的带宽,X轴和Y轴的带宽范围为0.5~1600Hz,Z轴的带宽范围为0.5~550Hz。
技术参数
工作电压:1.8~3.6V
功耗:350uA
测量范围:+3g
抗冲击能力:10,000g
外观尺寸:17.5 x 17.5mm
特点
1.小尺寸、薄、体积小
2.功耗极低
3.抗冲击
测试接线图
测试代码
//Analog read pins
const int xPin = 0;
const int yPin = 1;
const int zPin = 2;
//The minimum and maximum values that came from
//the accelerometer while standing still
//You very well may need to change these
int minVal =270;
int maxVal =440;
//to hold the caculated values
double x;
double y;
double z;
void setup(){
Serial.begin(9600);
}
void loop(){
//read the analog values from the accelerometer
int xRead = analogRead(xPin);
int yRead = analogRead(yPin);
int zRead = analogRead(zPin);
//convert read values to degrees -90 to 90 - Needed for atan2
int xAng = map(xRead, minVal, maxVal, -90, 90);
int yAng = map(yRead, minVal, maxVal, -90, 90);
int zAng = map(zRead, minVal, maxVal, -90, 90);
//Caculate 360deg values like so: atan2(-yAng, -zAng)
//atan2 outputs the value of -π to π (radians)
//We are then converting the radians to degrees
x = RAD_TO_DEG * (atan2(-yAng, -zAng) + PI);
y = RAD_TO_DEG * (atan2(-xAng, -zAng) + PI);
z = RAD_TO_DEG * (atan2(-yAng, -xAng) + PI);
//Output the caculations
Serial.print("x: ");
Serial.print(x);
Serial.print(" | y: ");
Serial.print(y);
Serial.print(" | z: ");
Serial.println(z);
delay(100);//just here to slow down the serial output - Easier to read
}
相关资料