I know there is another topic out there an exactly this but it seems to be going nowhere..
This is the LCD I am using x2 of course
and I am using an Arduino Mega2560
I have both LCD's connected to GND, 5v and the SDA and SCL connections, the code works fine but the problem is I am getting the same thing appearing on both displays at the same time
//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd1(0x24,16,2); // set the LCD address to 0x25 for a 16 chars and 2 line display
void setup()
{
lcd.init(); // initialize the lcd
lcd1.init(); // initialize the lcd
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(0,0); // set cursor to first character ont he first line
lcd.clear(); // clear anything that may be on the lcd screen
for(int i = 1; i <4; i++ ) { // creates blinking text - start of for loop complete the loop until i = 4, i increments each time the loop is run
lcd.print("Initializing!");
delay(1000); //delay for a time
lcd.clear();
delay(1000);
}
lcd.print("Complete!");
delay(2000);
lcd.clear();
lcd.print("Select Game");
lcd.setCursor(0,1); //change cursor location to second line
lcd.print("A=Bomb B=KOH");
}
// *************END of VOID Setup*************
any help much appreciated, if i can't get it working with these I will purchase some of the LCD's found in the thread, http://arduino.cc/forum/index.php/topic,5014.0.html .But would of course like to get the ones I have working
You can't change the address. It could be that the jumpers for A0, A1 and A2 are on the backside of the I2C interface pcb. Did you test the address with a I2C scanner?
I have used a scanner now and both devices report 0x27, however I am pretty sure that it is only reporting one device at a time regardless of whether one or two are attached.
At least now I understand one of the advantages of using a non IC2 display.
Until you post links to information about the specific devices that you are using and/or photographs of the devices, most of what you are going to get in response are guesses.
Many of the I2Ch devices seen on this forum use some variant of the '8574 8-bit I/O expander chip. These devices have three 'address' pins that can be connected in various combinations to either +5 v (logic 1) or to 0 v (logic 0). They also have a base address that is part of the design and cannot be changed.
Some of these devices have an 'A' in their suffix and some do not. The ones without a suffix have a base address of 0x20. This means that if the three address lines are connected to logic '0' the chip will have an address of 0x20 and if they are connected to +5 v they will have an address of 0x27. Other combinations give addresses between those extremes. What is happening is easier to see if you look at the binary versions of the addresses.
Your board may or may not have jumpers or solder pads that will enable you to change the address. That is where a photograph will enable us to help you.
Extracting this address information from the datasheet is possible but not easy due to several factors.
(1) Instead of placing the vital address information prominently on the first page it is typically buried deep within the document.
(2) The address is a 7-bit number where the highest bit is always '0'. This means that the first higit (hex digit) of the base address will never be higher than 7.
(3) In use the address is shifted one bit to the left to allow room to put a 'direction' (read or write) bit in the lowest position. The resulting 8-bit number is sometimes referred to as the chip address but it is not, it is the 'slave' address. You can recognize this situation because the first higit will be greater than 7.
(4) The diagram that explains the slave addresses, in every data sheet that I have, uses a bracket to misidentify the 7-bit shifted chip address for the 8574 as the slave address but it correctly identifies the 8-bit slave address for the 8574A.
Don
[Edit] (5) Some of the extender board manufacturers cleverly grind off the identification information from the IC so you cannot tell which version you have. You get what you pay for.
After a bit more digging it may be that the LCD is set to use 0x27 and cannot be changed, do you think this might be the case?
No.
If you have the device in that first link then on the back is a small blue block. Put a screwdriver in the slot of one of them and rotate it one click. The you should get a different address on that device. Check this with the I2C scanner.
Your board may or may not have jumpers or solder pads that will enable you to change the address. That is where a photograph will enable us to help you.
If you have the device in that first link then on the back is a small blue block.
I didn't scroll down to see that picture but are you sure that isn't the contrast pot for the LCD?
but are you sure that isn't the contrast pot for the LCD?
Now you mention it no I am not sure.
Pins 1, 2 & 3 are the address lines on that chip. Check what they are connected to with a meter. It might be they go out to the front or they could be just internally tied high or low.
If after powering them up they are the same on both displays then cut the wire on say pin 1 and connect it to ground if you measured it as being high, or if you measured it as being low connect it to +5V
However I think I am going to change to the non IC2 version of LCD's because If I want to make a few of the devices I don't want to have the check/change addresses and then recompile code for each individual device.
Thank you all for your responses, I had no idea(I could put a full stop here) about the addressing and the IC types so have gained some valuable knowledge.
get a transistor from say dig pin 3 via a 1k resistor to the base pin of the transistor, ok then (later you repeat for the 2nd screen)...
now the line responsible for sending data can be manipulated via thr base pin, by switching them off alternately you can update 2 screens, so the write side of i2c scl? would connect via the collector, emitter on the i2c scl or sda whichever it is...i think you can get away with it doing that...
But Let's suppose we did try this (and i'm certainly willing to try this) the multiplexing on the IC chip which deals with all the IO pins of the LCD device, once you've filled that shift register up and started making the chip do it's job to display "hello world"...
You should be safe to repeat the process using a transistor to control the data bus (allowing just 1 screen at a time to see what's on the bus)
But fine, maybe he's not up for this.... But I did not believe Technical Ability was the key issue here was... not being able to use 2 I2C screens were!
dexter,
I think you have a misunderstanding of how the I2C address for this chip is set.
It not something that can be set in s/w.
The i2c address is set in hardware. You have to strap the address lines of the chip.
From looking at the photo in the link your provided, appears that there is no easy way to set
the address. (There are no solder pads/jumpers on the top of the PCB).
Not all i2c backpacks that use that chp are designed like that one.
Most of them have solder jumper pads on the
PCB surface that faces out so you can change/alter it as needed without having
to desolder the PCB from the LCD.
It is possible that that the address of your boards can be set using pads on the back of the board,
but that would require de-soldering the backpack from the LCD to access it.
It is also possible that the boars you have may not support changing the address without modification.
Even if the boards do require modification, it is a fairly easy modification.
In fact, it might be easier to do the modification rather than de-solder
the board from the LCD as it only requires soldering a small jumper wire to one of the address pins
of the i2c chip to set it.
If you want to know if the back side of the board has address solder pads before you spend
the time de-soldering the PCB from the LCD, you might be able to see under the board
if you look carefully - perhaps use a mirror, and see if you can see 3 solder pads.
Otherwise, I suggest you send a message to the seller and ask him how to set the i2c address.
According to the ebay page you linked to:
Does this seller have 20 years of technical experience to support any problems you may have?
If you buy this item from us, the answer to all of the above is… YES!
He should be able to easily answer the question of whether this board
can set the i2c address. It would be even better if he could provide you a photo
of the back of the board.
(but even if it can be set by solder on the back of the PCB it still might be less work
to solder a small wire to the i2c chip instead)
There some other details that would be nice to know and are perhaps needed.
I would hammer the seller to cough up a schematic, then you will get the additional
information, like how the backlight is controlled (does it use a transistor, or
is the i2c chip attempting to drive it directly).
And how the i2c chip output pins are wired to the LCD.
This information is vital if you want to use an i2c lcd library like fm's new LiquidCrystal library
as you will need to fill in the pin details into the i2c constructor to tell the library
which i2c chip pins are hooked up to which lcd pins.