问下怎么找i2c上陀螺仪或者加速计的地址呢?
arduino吧
全部回复
仅看楼主
level 11
A猛蹬125V 楼主
如题,虽说我照网上的代码已经能读数了。。。可是还是不太明白,如果要和舵机MAP的话应该怎么处理?
2013年07月17日 15点07分 1
level 11
A猛蹬125V 楼主
求各位大神
2013年07月17日 16点07分 2
level 9
其实是用个小程序一个个扫过去的
原文地址:http://playground.arduino.cc/Main/I2cScanner
说不定会被吞
2013年07月17日 19点07分 3
level 9

#include <Wire.h>
void setup()
{
Wire.begin();
Serial.begin(9600);
Serial.println("\nI2C Scanner");
}
void loop()
{
byte error, address;
int nDevices;
Serial.println("Scanning...");
nDevices = 0;
for(address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");
nDevices++;
}
else if (error==4)
{
Serial.print("Unknow error at address 0x");
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");
delay(5000); // wait 5 seconds for next scan
}
2013年07月17日 19点07分 4
其实就是一个个试…… 代码是arduino官网playground的i2cScanner
2013年07月17日 19点07分
回复 fanqi1234 :十分感谢
2013年07月18日 01点07分
level 11
了解一下该总线工作原理就知道了。
2013年07月18日 16点07分 5
1