I'm getting this error whenever I use a variable to define an address using the requestFrom function in the Wire.h library:
"error: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
Wire.requestFrom(max6965, 1); //TROUBLED LINE
if(1 <= Wire.available()) // if 1 byte was received
{
reading = Wire.receive(); // receive high byte (overwrites previous reading)
Serial.print("RAM Holds: ");
Serial.println(reading); // print the reading
} else {
Serial.println("Sorry, the LED ram appears to hold no data");
}
Serial print stuff is just for debugging. Any ideas? I'm guessing this has to do with how the variables are handled in the actual Wire.h library. I tried declaring max6965 as an int or a byte when passing it into the wire.requestFrom function but it didn't help.
You need to turn the "byte max6965" to an "int max6965"
I just with some of my code, and got the same error. I can't really try with your code.. seeing as it's not really full code.
But next time you post some code, you should make use of the "#" sign on the toolbar when typing. This just makes your code easy to read, and gives it a scrollbox so it doesn't take up 3 pages of your screen. (longer code of course:P)
Wire.requestFrom((int)max6965, 1); //TROUBLED LINE
Wire.requestFrom(max6965, (byte)1); //TROUBLED LINE
What's going on is the compiler assumes "1" is an int. Functions taking two parameters often complain when you pass them one byte and one int rather than two bytes or two ints. The reason frequently is that there are (int, int) and (byte, byte) versions of the function, so the compiler doesn't know which one to use when you pass it one byte and one int.
And this way you save a whole byte of RAM because you keep your variable a byte!