ADXL335加速度传感器的使用问题
先说一下我的代码:/*
ADXL335
note:vcc-->5v ,but ADXL335 Vs is 3.3V
The circuit:
5V: VCC
analog 1: x-axis
analog 2: y-axis
analog 3: z-axis
*/
const int xpin = 1; // x-axis of the accelerometer
const int ypin = 2; // y-axis
const int zpin = 3; // z-axis (only on 3-axis models)
void setup()
{
// initialize the serial communications:
Serial.begin(9600);
}
void loop()
{
int x = analogRead(xpin);
delay(1); //
int y = analogRead(ypin); //
delay(1);
int z = analogRead(zpin);
float zero_G = 512.0; //ADC is 0~1023the zero g output equal to Vs/2
//ADXL335 power supply by Vs 3.3V
float scale = 102.3;//ADXL335330 Sensitivity is 330mv/g
//330 * 1024/3.3/1000
Serial.print(((float)x - zero_G)/scale);
Serial.print("\t");
Serial.print(((float)y - zero_G)/scale);
Serial.print("\t");
Serial.print(((float)z - zero_G)/scale);
Serial.print("\n");
delay(500);
}
在测量加速度的时候,理论结果应该是0,0,1,水平放置的话。
但实际结果呢是
求大神问下这是怎么回事???
对于这个,有什么错误么?
:Q好巧,我也在研究这个 找不到好的说明 帮顶 我想计算角度啊 自己一只 发表于 2015-10-14 19:52 static/image/common/back.gif
好巧,我也在研究这个 找不到好的说明 帮顶 我想计算角度啊
修改参数 角度数 的公式不一样 修改一下就可以了 564764406 发表于 2015-10-19 08:43 static/image/common/back.gif
修改参数 角度数 的公式不一样 修改一下就可以了
想问一下,该怎么做,搜了好多地方没搜到怎么调零(也许搜得东西不对)请指教! 想问一下楼主 adxl335的电源接的是3.3V还是5 v?还有板子上的AREF接3.3v还是不接呢?
页:
[1]