弘毅版主给个ADXL345和ITG3200连接的电路图吧
在这个帖子里面有面包版连接图,看不清楚啊
http://www.geek-workshop.com/forum.php?mod=viewthread&tid=236
嘛叫SPI接口,I2C又是神马东东,硬件小白伤不起啊伤不起
麻烦给个电路图研究学习一下,谢谢! 这两个模块因为都用的I2C接口,传感器的PCB板子上除了VCC和GND,还会有SCL,SDA两个接口。(PCB板子上对应的接口会标着。)
arduino板子的模拟5号口连接I2C模块的SCL,模拟4号口连接I2C模块的SDA口。
VCC与GND正常连接,主要不要接错电压,要使用3.3V。如果把5V接到3.3V上,就会烧了IC。
I2C模块之间是并联关系~
电源就不写了。。随便画一下SCL与SDA接法。
本帖最后由 SS15 于 2012-2-21 11:04 编辑
原来想着ADXL345应该很简单,实际弄了一下才发现不是那么回事。345有I2C和SPI两种接法,I2C的SDO脚接不同的地方设备地址又不一样,简单说就是不同设计的模块需要不同的程序代码
简直就是坑害小白啊,不过总算搞定了。
谢谢版主
#include "Wire.h"
#define DEVICE (0x53) // ADXL345 device address when the SDO pin (12) is grounded
// 推荐的I2C模式电气连接。器件的7位I2C地址是 0x53
void setup()
{
Serial.begin(115200); // start serial for output
Wire.begin(); // join i2c bus (address optional for master)
// Wake up the accelerometer
Wire.beginTransmission(DEVICE); // Start talking to the ADXL345 accelerometer on the SEN-10183 board: http://www.sparkfun.com/products/10183
Wire.send(0x2D); // The address on the accel we want to set: POWER_CTL
Wire.send(0x08); // The value on the address: Measure(8), START MEASUREMENT
Wire.endTransmission();
}
void loop()
{
// Ask the accel to send us it's XYZ values
Wire.beginTransmission(DEVICE); // Start talking to the ADXL345 accelerometer on the SEN-10183 board: http://www.sparkfun.com/products/10183
Wire.send(0x32); // The address on the accel we want to read
Wire.endTransmission();
// Receive the XYZ values
Wire.requestFrom(DEVICE, 6); // Request bytes from another device, Wire.requestFrom(address, quantity)
byte data;
for (int i=0;i<6 && Wire.available();i++)
{
data = Wire.receive();
}
Wire.endTransmission();
// Parse them
int x = data | (((int)data)<<8);
int y = data | (((int)data)<<8);
int z = data | (((int)data)<<8);
char buf;
sprintf(buf, "x:%d, y:%d, z:%d\r\n", x,y,z);
Serial.print(buf);
delay(200);
}
SS15 发表于 2012-2-21 11:00 static/image/common/back.gif
原来想着ADXL345应该很简单,实际弄了一下才发现不是那么回事。345有I2C和SPI两种接法,I2C的SDO脚接不同的 ...
:lol是滴,这个我当时也琢磨了好久。。自己焊模块的时候~~
页:
[1]