I just downloaded his latest library, copied it to my libraries folder, restarted the IDE, opened the example, and compiled it, without errors.
Where did you store the files and did you need to do anything else to link the I2C.h file?
I keep getting this 'I2c' was not declared in this scope error
on the I2c.begin() line of code
Inside I2C_Rev5.zip is a folder, "I2C".
Copy that to the "libraries" folder which is under where your sketches folder is (the whole folder, not just its contents).
Restart the IDE.
Then it should work.
And, you've been told that it is I2C, not I2c. Don't come back until you fix that.
Thanks Nick!
I thought that I did restart the IDE but I had another instance of it running in the background.
I closed all instances of the IDE and then stated up one instance of it and then I was able to import the library.
I like your scan utility and would like to incorporate that into checking for the device
before reading it but not sure how to convert it over to the I2C.h library functions for the following:
Wire.beginTransmission (i);
if (Wire.endTransmission () == 0)
PaulS:
And, you've been told that it is I2C, not I2c. Don't come back until you fix that.
Fix I2c Again???
Wasn't the problem... I2c is correct and as I posted prior to your reply, that is the way that is was in the sample code that came with the library.
I later found out (thanks to Nick's post) that the sample code did not work for me because I hadn't restarted the IDE and loaded the library...
but thanks all the same...
irethedo:
I like your scan utility and would like to incorporate that into checking for the device
before reading it but not sure how to convert it over to the I2C.h library functions for the following:
Looking at the source, the library has a scan function. Look at how that does it:
void I2C::scan()
{
uint16_t tempTime = timeOutDelay;
timeOut(80);
uint8_t totalDevicesFound = 0;
Serial.println("Scanning for devices...please wait");
Serial.println();
for(uint8_t s = 0; s <= 0x7F; s++)
{
returnStatus = 0;
returnStatus = start();
if(!returnStatus)
{
returnStatus = sendAddress(SLA_W(s));
}
if(returnStatus)
{
if(returnStatus == 1)
{
Serial.println("There is a problem with the bus, could not complete scan");
timeOutDelay = tempTime;
return;
}
}
else
{
Serial.print("Found device at address - ");
Serial.print(" 0x");
Serial.println(s,HEX);
totalDevicesFound++;
}
stop();
}
if(!totalDevicesFound){Serial.println("No devices found");}
timeOutDelay = tempTime;
}