0

Question:

The follow code is printing 10 over and over again (with spaces in between). I have an I2C device connected at 0x60, and nothing connected at 0x61. I'm confused by this because the Wire.endTransmission(bool) docs say the only valid return types are 0,1,2,3, and 4. These return types are further supported by the Wire.endTransmission(), and the source code of the twi_writeTo function calls.

Code:

```

#include <Wire.h>

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Adafruit Motorshield v2 - DC Motor test!");

}

void loop() {
  // put your main code here, to run repeatedly:
  shieldConnected(0x60);
  Serial.println("\n");
  shieldConnected(0x61);

  delay(2000);

}

/** 
 * Checks if an I2C device is connected at shieldAddr. This effectively checks if a 
 * motor shield exists at that location.
 * 
 * Note, this only works when everything's imported for some reason.
 */
void shieldConnected(uint8_t shieldAddr){
  Wire.beginTransmission(shieldAddr);
  Wire.write(1);
  uint8_t end = Wire.endTransmission(true);
  //shieldAddressValidator(shieldAddr);
  Serial.println(end);
}

```

  • Which arduino board do you use? Is that a working sketch? Are there spaces in between or new lines? Can you print it as a int. – Jot Dec 18 '18 at 21:55
  • Genuino 101, Yes, yes, and I can change it to printf if that's what you mean? – user4757074 Dec 18 '18 at 23:00
  • I'm sorry but I have bad news. The Arduino/Genuino 101 uses a Intel processor and it was a shame. There are different parts (serial, i2c) that never became fully compatible. There might be no solution to your problem or any problem with the 101. Buy a normal board that is compatible with the adafruit motor shield v2. – Jot Dec 18 '18 at 23:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.