sumotoy
Well-known member
I'm tying to write a simple I2C scanner but since seems I cannot use the twi.h lib I've tried to use the ability of wire.endTransmission() function to check if device acknoledge.
small example
This will aways return all devices found since wire.endTransmission() on teensy 3 always return 0! Th's a way to get around this?
small example
Code:
byte dummy;
for (char id=1; id<=100; id++) {
Wire.beginTransmission(id);
Wire.write(&dummy, 0);
if (Wire.endTransmission() == 0)
{
Serial.print("[[0x");
Serial.print(id,DEC);//found
Serial.print("]] ");
}
else {
Serial.print("0x");
Serial.print(id,DEC);
Serial.print(" ");
}
}
This will aways return all devices found since wire.endTransmission() on teensy 3 always return 0! Th's a way to get around this?