Go Down

Topic: LCD2004 Help (Read 5004 times) previous topic - next topic

wiblish

Hello there, I'm completely clueless on what to do to get this LCD display working.
I'm a bit of a newbie to Arduino, and I don't know what to do.
--------------------------------------------------------------------------------------------
I got this
http://www.sainsmart.com/sainsmart-iic-i2c-twi-serial-2004-20x4-lcd-module-shield-for-arduino-uno-mega-r3.html
for Christmas, and I also have an Arduino Uno.

I've tried seeking internet help, and I wired it to my best ability, but the display's backlight glows by itself, or the display backlight glows and the grid of characters are all lit up.

I've read about these things called Arduino Shields? Do I require one to use this LCD display?
I'd much rather wire it directly from the Arduino Uno to the LCD2004.

Sorry if I'm not being clear, again I'm new to this, and not sure what to do.
Please ask questions if I'm not being clear.

I just need to know how to hook the Arduino Uno up to the LCD2004, and if I need any additional materials.
Thanks.

floresta

#1
Jan 14, 2013, 01:55 am Last Edit: Jan 14, 2013, 02:00 am by floresta Reason: 1
We have dealt with this display in the past so why don't you start by putting 'Sainsmart LCD2004' into the search box at the upper right and see what pops up.   Pay particular attention to any information about pull-up resistors and I2C addresses and also about which library is recommended.

Quote
I've read about these things called Arduino Shields? Do I require one to use this LCD display?
I'd much rather wire it directly from the Arduino Uno to the LCD2004.


If you use the I2C interface you really don't need or want to use a shield.

Don

tack

#2
Jan 14, 2013, 09:49 am Last Edit: Jan 14, 2013, 09:57 am by tack Reason: 1
First off, I'd recommend you download and install the New Liquid Crystal Library, to replace the default one that comes with your IDE installation.

https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads

Make sure you remove the existing standard LiquidCrystal and LiquidCrystal_I2C libraries. Don't just rename them, you have to remove them from the 'libraries' folder completely or there will be a conflict.

The Sainsmart example code seems to suggest that their I2C backpack is wired in the 'standard' way for the I2C library, but there is an obvious mistake in the page telling you that the interface is on 0x3F, but the example code is for 0x27.

Try the code below, but if it doesn't work with the 0x3F address then try running the I2C Scanner sketch from the Arduino Playground, and it will report the addresses it finds. The replace 0x3F against lcdAddrin the example below with the address you find.

Connect as follows

Code: [Select]

LCD Backpack > Arduino
Vcc          > +5V, via a 100 Ohm resistor
Gnd          > Gnd
SCL          > Pin A5
SCK          > Pin A4


The resistor is there to protect the LED backlight. I would guess the LCD module has a resistor anyway, so if the display backlight is dim then you can probably remove this resistor afterwwards and wire Vcc directly to +5V

Once you've done all the above then use the sketch below and compile + upload. Report back whether this has you up and running.

Code: [Select]
include <Wire.h>
#include <LiquidCrystal_I2C.h>

#define lcdAddr 0x3F // set the address of the I2C device the LCD is connected to

// create an lcd instance
LiquidCrystal_I2C lcd(lcdAdrr); // I2C addr

// Creat a set of new characters
const uint8_t charBitmap[][8] = {
  { 0xc, 0x12, 0x12, 0xc, 0, 0, 0, 0 },
  { 0x6, 0x9, 0x9, 0x6, 0, 0, 0, 0 },
  { 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0, 0x0 },
  { 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0, 0x0 },
  { 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0x0 },
  { 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0x0 },
  { 0x0, 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0x0 },
  { 0x0, 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0x0 }
 
};

void setup()
{
  int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0]));

 lcd.begin(20,4);  // initialize the lcd as 20x4 (16,2 for 16x2)
 
 lcd.setBacklight(1); // switch on the backlight

 for ( int i = 0; i < charBitmapSize; i++ )
  {
     lcd.createChar ( i, (uint8_t *)charBitmap[i] );
  }

 lcd.home ();  // go home to character 0 on line 0 (1st line)
 lcd.print("Hello, ARDUINO ");  
 lcd.setCursor(0,1);  // character 0 on line 1 (2nd line)
 lcd.print (" FORUM - fm   ");
 lcd.setCursor(0,2); // character 0 on line 2 (3rd line)
 lcd.print("This is line 3");
 lcd.setCursor(0,3); // character 0 on line 3 (4th line)
 lcd.print("This is line 3");
 delay(1000);
}

void loop()
{
  lcd.clear();
  lcd.home ();
  // Do a little animation by writing to the same location
  for ( int i = 0; i < 2; i++ )
  {
     for ( int j = 0; j < 16; j++ )
     {
        lcd.print (char(random(7)));
     }
     lcd.setCursor ( 0, 1 );
  }
  delay (200);
}

LETARTARE

#3
Jan 14, 2013, 12:15 pm Last Edit: Jan 14, 2013, 12:18 pm by LETARTARE Reason: 1
*********************** Translation by GOOGLE *********************
Hello,
The library provided by SaintSmart (LiquidCrystal_I2C.rar) version only works with Arduino 023 !!!
Also check your display load Arduino 023. Then test the display.

The library LiquidCrystal_V1.2.1.zip can not control LCD20x4 SaintSmart because of the pinout of the display on the I2C component is different!
It is therefore necessary to adapt the library  provided by SaintSmart Arduino versions> = 100.

I made this adaptation in the zip file attached.
This version works with Arduino 103 and the display SaintSmart LCD20x04 in VISTA PRO.
I provided the library with your own risk!

Sincerely.
***************************************************************************
Bonjour,
la bibliothèque fournie par SaintSmart ( LiquidCrystal_I2C.rar) ne fonctionne qu'avec la version Arduino 023 !!!
Aussi pour vérifier votre afficheur charger Arduino 023 . Puis tester l'afficheur.

La biblothèque LiquidCrystal_V1.2.1.zip  ne peut pas piloter LCD20x4 de SaintSmart car le brochage de l'afficheur  sur le composant I2C est différent !!
Il faut donc adapter la biblothèque fournie par SaintSmart aux versions Arduino >= 100.

J'ai fait cette adaptation dans le fichier zip ci-joint.
Cette version fonctionne avec Arduino 103 et l'afficheur SaintSmart LCD20x04 sur VISTA PRO.
Je fourni cette bibliothèque à vos risques et périls !

Bien cordialement.

tack

The new liquidcrystal library will work with just about any character based LCD.

From what I can find on the wiring it looks like the Sainsmart uses a seperate pin for backlight, rather than controls via the I2C bus.

Therefore you may need to wire this to an Arduino pin and declare it, i.e connect to pin 9 and declare as such.

You may also need to use a constructor that sets the connection bit order:

Code: [Select]
#define BACKLIGHT_PIN 9
LiquidCrystal_I2C lcd(lcdAdrr,2,1,0,4,5,6,7); // Addr, EN, RW, RS, D4, D5, D6, D7

LETARTARE

@tack
******************** by Google ****************
hello,
thank you for your reply.
I just did the test with Arduino 103 LiquidCrystal_I2C v1.21 and your code:
Code: [Select]
LiquidCrystal_I2C LCD (lcdAdrr, 2,1,0,4,5,6,7) // Addr, EN, RW, RS, D4, D5, D6, D7
it does not work.

Indeed the display that I have (Saintsmart LCD20x4 J204A) address is set to:
Quote
lcdaddr = 0x3F

pins are wired on the PCA857A :
Quote
En = 6, RW = 5, RS = 4, D4 = 0, D5 = 1, D6 = 2, D7 = 3


Even in writing:
Code: [Select]
LiquidCrystal_I2C LCD (0x3F, 6, 5, 4, 0, 1, 2, 3);
it does not work, just flash!

A new library DFRobot which works well with J204A:
http://www.dfrobot.com/image/data/DFR0154/LiquidCrystal_I2Cv1-1.rar

Sincerely
******************************************************************************
bonjour,
merci de votre réponse.
Je viens de faire le test avec Arduino 103, LiquidCrystal_I2C v1.21  et votre code :
Code: [Select]
LiquidCrystal_I2C lcd(lcdAdrr,2,1,0,4,5,6,7); // Addr, EN, RW, RS, D4, D5, D6, D7
cela ne fonctionne pas.

En effet sur l'afficheur que je possède ( Saintsmart LCD20x4 J204A)  l'adresse  a pour valeur :
Quote
lcdaddr = 0x3F

les broches sont cablées sur le PCA8574 :
Quote
En = 6, RW = 5, RS = 4, D4 =0, D5 = 1, D6 = 2, D7 = 3,


Même en écrivant :
Code: [Select]
LiquidCrystal_I2C lcd(0x3F, 6, 5, 4, 0, 1, 2 , 3);
cela ne fonctionne, seulement des flashs !

Une nouvelle bibliothèque de dfrobot qui fonctionne bien avec le J204A :
http://www.dfrobot.com/image/data/DFR0154/LiquidCrystal_I2Cv1-1.rar

Bien cordialement

bperrybap


@tack
******************** by Google ****************
hello,
thank you for your reply.
I just did the test with Arduino 103 LiquidCrystal_I2C v1.21 and your code:
Code: [Select]
LiquidCrystal_I2C LCD (lcdAdrr, 2,1,0,4,5,6,7) // Addr, EN, RW, RS, D4, D5, D6, D7
it does not work.

Indeed the display that I have (Saintsmart LCD20x4 J204A) address is set to:
Quote
lcdaddr = 0x3F

pins are wired on the PCA857A :
Quote
En = 6, RW = 5, RS = 4, D4 = 0, D5 = 1, D6 = 2, D7 = 3


Even in writing:
Code: [Select]
LiquidCrystal_I2C LCD (0x3F, 6, 5, 4, 0, 1, 2, 3);
it does not work, just flash!

A new library DFRobot which works well with J204A:
http://www.dfrobot.com/image/data/DFR0154/


The code referenced in the DFRobot link shows everything you need to fill in the constructor
the DFRobot code uses:
Code: [Select]

I2c Bit LCD
3 Backlight (positive logic)
2 EN
1 R/W
0 RS
4 D4
5 D5
6 D6
7 D7


This pin wiring specified by LETARTARE is incorrect
Quote
En = 6, RW = 5, RS = 4, D4 = 0, D5 = 1, D6 = 2, D7 = 3

according to the working code in the DFRobot link .

The constructor that tack gave was correct and did work, except for the backlight
and since this display uses an inverted display you won't see anything until you
turn on the backlight.
So if the address is 0x3f, the full constructor would be:
Code: [Select]
LiquidCrystal_I2C  lcd(lcdAdrr, 2,1,0,4,5,6,7, 3, POSITIVE);

--- bill
   

LETARTARE

#7
Jan 15, 2013, 10:21 am Last Edit: Jan 16, 2013, 04:02 pm by LETARTARE Reason: 1
********************* by GOOGLE ****************************
@bperrybap
hello,
thank you for this response which tells me that I need to reread several times what I write.
I'm confused !!
I reversed two libraries (I have download a dozen !)
http://hmario.home.xs4all.nl/arduino/LiquidCrystal_I2C/ with
http://hmario.home.xs4all.nl/arduino/LiquidCrystal_I2C/LiquidCrystal_I2C.zip
that it uses:
Code: [Select]
# define In B00010000 / / Enable bit
# define Rw B00100000 / / Read / Write bit
# define Rs B01000000 / / Register select bit


With your library DFRobot v1.1 your code:
Code: [Select]
LiquidCrystal_I2C LCD (lcdAdrr, 2,1,0,4,5,6,7, 3 POSITIVE)
work properly.

A thousand apologizes for the confusion!
Cordially.
****************************************************************************
bonjour,
merci de cette réponse qui m'indique qu'il faut relire plusieurs fois ce que l'on écrit.
Je suis confus !!
J'ai inversé deux librairies ( j'ai du en charger une bonne dizaine !!) :
http://hmario.home.xs4all.nl/arduino/LiquidCrystal_I2C/ avec
http://hmario.home.xs4all.nl/arduino/LiquidCrystal_I2C/LiquidCrystal_I2C.zip
qui elle utilise :
Code: [Select]
#define En B00010000  // Enable bit
#define Rw B00100000  // Read/Write bit
#define Rs B01000000  // Register select bit


Avec votre librairie DFRobot v1.1 , votre code :
Code: [Select]
LiquidCrystal_I2C  lcd(lcdAdrr, 2,1,0,4,5,6,7, 3, POSITIVE);
fonctionne correctement.

Encore mille excuses pour cette confusion !!!
Bien cordialement.


bperrybap


********************* by GOOGLE ****************************
With the library DFRobot v1.1 your code:
Code: [Select]
LiquidCrystal_I2C LCD (lcdAdrr, 2,1,0,4,5,6,7, 3 POSITIVE)
work properly.


That constructor is for fm's library not the DFRrobot library:
https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads

--- bill

LETARTARE

Of course !!
cordially.

ytrewq

I have what appears to be the same LCD 4X20 display that I want to work with my Arduino Uno, rev. 3.
http://www.amazon.com/gp/product/B003B22UR0/ref=oh_details_o00_s00_i00
I followed the reply to mssg below, which suggested searching on 'LCD sainsmart', and I did.  I went through all of those messages and loaded all of the libraries.  Nothing worked, and I tried fixing the device address and typos in some of them, still with no success.  One of them did make the backlight flicker.  I have tried wiring it with SDA/SCL to the SDA/SCL on the Uno.  I also tried using A4/A5, reversing them. Nada.

I wrote to wiflish to see if he ever got it to work, got no reply.   

Thanks for any help.


Hello there, I'm completely clueless on what to do to get this LCD display working.
I'm a bit of a newbie to Arduino, and I don't know what to do.
--------------------------------------------------------------------------------------------
I got this
http://www.sainsmart.com/sainsmart-iic-i2c-twi-serial-2004-20x4-lcd-module-shield-for-arduino-uno-mega-r3.html
for Christmas, and I also have an Arduino Uno.

I've tried seeking internet help, and I wired it to my best ability, but the display's backlight glows by itself, or the display backlight glows and the grid of characters are all lit up.

I've read about these things called Arduino Shields? Do I require one to use this LCD display?
I'd much rather wire it directly from the Arduino Uno to the LCD2004.

Sorry if I'm not being clear, again I'm new to this, and not sure what to do.
Please ask questions if I'm not being clear.

I just need to know how to hook the Arduino Uno up to the LCD2004, and if I need any additional materials.
Thanks.

tack


I have what appears to be the same LCD 4X20 display that I want to work with my Arduino Uno, rev. 3.
http://www.amazon.com/gp/product/B003B22UR0/ref=oh_details_o00_s00_i00
I followed the reply to mssg below, which suggested searching on 'LCD sainsmart', and I did.  I went through all of those messages and loaded all of the libraries.  Nothing worked, and I tried fixing the device address and typos in some of them, still with no success.  One of them did make the backlight flicker.  I have tried wiring it with SDA/SCL to the SDA/SCL on the Uno.  I also tried using A4/A5, reversing them. Nada.

I wrote to wiflish to see if he ever got it to work, got no reply.   

Thanks for any help.

If it's the sainsmart then try looking at the following post and report back:-

http://arduino.cc/forum/index.php?topic=106655.0

Go Up