谁用过这个MMA7455模块?~~~我尝试很多次读出的值都是0
#include <Wire.h>
#define ACCELEROMETER 0x1D //Address for Accelerometer
#define MODE_CONTROL 0x16 //Mode control register
#define PULSE_DET 0x1B //Pulse detection threshold limit value
#define X_OUT 0x06 //8 bit register containing value for X
#define Y_OUT 0x07 //8 bit register containing value for Y
#define Z_OUT 0x08 //8 bit register containing value for Z
#define DETECTION 0x0A //Detection source register
#define Z_PULSE 0x40 //Pulse detected on Z-axis
#define SENSEVALUE 0x25 //Default sensitivity level
void setup() {
Wire.begin();
Serial.begin(9600);
accWrite(MODE_CONTROL, SENSEVALUE);
}
void loop() {
Serial.print("X: ");
Serial.print(accRead(X_OUT),DEC);
Serial.print(" Y: ");
Serial.print(accRead(Y_OUT),DEC);
Serial.print(" Z: ");
Serial.println(accRead(Z_OUT),DEC);
delay(100);
}
//function to write byte data into a register
void accWrite(byte address, byte data) {
Wire.beginTransmission(ACCELEROMETER);
Wire.send(address);
Wire.send(data);
Wire.endTransmission();
}
char accRead(byte address){
char val = 0;
Wire.beginTransmission(ACCELEROMETER);
Wire.send(address);
Wire.requestFrom(ACCELEROMETER, 1);
val = Wire.receive()
Wire.endTransmission();
return val;
}
[解决办法]
用过MMAXXXX的,不过不是这个型号
你这个程序不完整
[解决办法]
首先确定硬件连接OK,否则再好的程序都白费;然后认真核对手册说明了,确定寄存器配置正确了,这些工作只能靠你自己了。。。
[解决办法]
我的也是,测试不出来啊
[解决办法]
请问你用的什么通信方式?