i2c Address code for Arduino display..

hello, i am struggling at the moment as i am trying to create a prototype for a class assignment (worth 12 credits) and what i am trying to make is a sonic sensored car that also displays the amount of cm that an object is in front of it. There are three codes and i am stuck on the i2c address for the display.

Code: #include <Wire.h>

void setup()
{
Wire.begin();

Serial.begin(9600);
while (!Serial); // Leonardo: wait for serial monitor
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
}

All i get is the stupid “”
Invalid library found in E:\Compy\Program Files (x86)\Arduino\libraries\i2c_scanner: E:\Compy\Program Files (x86)\Arduino\libraries\i2c_scanner “”

Any suggestions? I have looked on forums but found no answers that helped…
Much appreciated

What kind of display is it? Do you have a link?

All i get is the stupid ""
Invalid library found in E:\Compy\Program Files (x86)\Arduino\libraries\i2c_scanner: E:\Compy\Program Files (x86)\Arduino\libraries\i2c_scanner ""

This looks wrong. Why is the i2c_scanner program in the IDE libraries folder?

You have changed the Arduino system files.
Please delelete E:\Compy\Program Files (x86)\Arduino
Download the Arduino IDE and install it.

Start the Arduino IDE. Create a new sketch, replace the empty sketch with the i2c_scanner code ( http://playground.arduino.cc/Main/I2cScanner ). Save it. Upload it. Open the serial monitor.

Arduino is saved/installed to the e drive to speed up he computer. Should I remove it from C:/program86x/arduino?

I don’t know. I can’t imagine that a copy to another driver would be faster. Is the C: drive a network drive ?
Somehow the Arduino system files are changed, because the compiler seems to think that the i2c_scanner is in the system libraries. I’m afraid that more is changed, that is why I advice to make fresh new install of the Arduino IDE.

Koepel:
I don't know. I can't imagine that a copy to another driver would be faster. Is the C: drive a network drive ?
Somehow the Arduino system files are changed, because the compiler seems to think that the i2c_scanner is in the system libraries. I'm afraid that more is changed, that is why I advice to make fresh new install of the Arduino IDE.

I'm going to save the new downlaod on the e drive. Can I do that or will it cause the same problems??

I'm going to save the new downlaod on the e drive. Can I do that or will it cause the same problems??

Should be fine, and if there are problems it's easy to recover so if that's where you want it give it a try.

Where is your sketches and user libraries folder located? You may have to point the IDE to that location.

You can do that through File>Preferences>Sketchbook Location

cattledog:
Should be fine, and if there are problems it's easy to recover so if that's where you want it give it a try.

Where is your sketches and user libraries folder located? You may have to point the IDE to that location.

You can do that through File>Preferences>Sketchbook Location

uploaded program YAY! but i2c address code not working

but i2c address code not working

Come on Anthropous, help us out here.

Does it compile? Does it hang up and return nothing? Does it show no devices?

cattledog:
Come on Anthropous, help us out here.

Does it compile? Does it hang up and return nothing? Does it show no devices?

cattledog:
Come on Anthropous, help us out here.

Does it compile? Does it hang up and return nothing? Does it show no devices?

Sorry Catdog

Compiles, uploads but display shows nothing, display is on and arduino board says its recieved the code. could it be the display??

((BTW its a ywrobot arduino display, lcm1602 ||c v1, 4 prongs..))

display shows nothing

First things first.

What does the scanner program report. Can the display be seen in the i2c bus?

#include <Wire.h>
 
 
void setup()
{
  Wire.begin();
 
  Serial.begin(9600);
  while (!Serial);             // Leonardo: wait for serial monitor
  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
}

have this if it helps

7af4eff5-fbe3-46df-bd7a-23f0ffe78223.png

92ead60a-81e7-4cdb-a689-a4cb04c2e9ef.png

cattledog:
First things first.

What does the scanner program report. Can the display be seen in the i2c bus?

#include <Wire.h>

void setup()
{
  Wire.begin();

Serial.begin(9600);
  while (!Serial);            // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner");
}

compiling sketch, uploading, done. nothing else happens… display shows nothing once uploaded

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
}

Sketch uses 4,130 bytes (12%) of program storage space. Maximum is 32,256 bytes.
Global variables use 522 bytes (25%) of dynamic memory, leaving 1,526 bytes for local variables. Maximum is 2,048 bytes.
thats it

Please verify that the serial monitor is set to 9600 baud. There is a little box at the lower right hand corner of the serial monitor window where you can set the baud rate. The rate in the monitor must be the same as the the rate set in the sketch with Serial.begin(9600).

The Serial.println() functions print text to the "serial monitor". You have to open the "serial monitor".
It is a small button in the upper-right corner of the Arduino IDE (a quare button with dots and a magnifier).

It is also in the menu : Tools / Serial Monitor Ctrl + Shift + M

The I2C bus for a Arduino Uno is at pin A4 and A5. Pin A4 is SDA and pin A5 is SCL.
The same SDA and SCL pins are near the USB connector.

Could you select the proper pins and make a photo of that ? so we can verify it ?

cattledog:
Please verify that the serial monitor is set to 9600 baud. There is a little box at the lower right hand corner of the serial monitor window where you can set the baud rate. The rate in the monitor must be the same as the the rate set in the sketch with Serial.begin(9600).

it is set to 9600baud

done, somehting happend so i reboted my computer, now it is being picked up by the serial monitor.

heres the photo, (( if it uploads, says needs admin to moderate or something))

5adb5aa0-a345-41ce-9ffa-9c2c1f1cd4ca.png

Thanks for the photo, those are the I2C pins.
What is the output of the i2c_scanner ? The output is the text in the serial monitor.