Pages: [1] 2 3 4   Go Down
Author Topic: SainSmart 20 x 4 LCD wanting to use I2C from Arduino Uno  (Read 15373 times)
0 Members and 1 Guest are viewing this topic.
Raleigh, NC.
Offline Offline
Full Member
***
Karma: 0
Posts: 129
Addicted to Arduino
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello all,

I have been using arduino for awhile, but this is my first post in the forums. I have built a project that is working fine using the 6 data pins that I declare in my code:


LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

but my senior partners and I in my class would like to imply more use of the Digital Pin outs especially the SPI pin outs, so I have decided to try the I2C route. Now I have connected Pin analog 4 (SDA ) and analog 5 (SDL) to the resepective Two wire interface for the board on the back of the 20 x 4 LCD as well as VCC and GND.

All the test code provided online doesn't work, I have arduino 1.0  and arduino 1.0.1 and it is kicking my @$$ on trying to get some readout on the LCD at all...I can get it to load using this code:
Code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27 20,4); //set the LCD address to 0x27

void setup()
{
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("b2cqshop");
lcd.setCursor(0, 1);
lcd.print("Voltage: ");
lcd.setCursor(13, 1);
lcd.print("V");
}
void loop()
{
int val;
float temp;
val=analogRead(0);
temp=val/4.092;
val=(int)temp;//
lcd.setCursor(9, 1);
lcd.print(0x30+val/100);
lcd.print(0x30+(val%100)/10);
lcd.print('.');
lcd.print(0x30+val%10);
delay(100);
}


but the LCD just doesn't do anything......I know all about the ACK bit for the 7 / 8 bit transfer using I2C and the wire library needs to be included which it is.....

IS THERE ANYONE OUT THERE THAT HAS DONE a simple Arduino Uno to I2C LCD  that could step me through some simple basics to get any readout on the 20 x 4 LCD...direct me to a proper library ...something....

the 4 wire harness I have is fine as well (Ohmed it out..) ...Pot for contrast is good too....

Please Please help

Aaron

Moderator edit: Code tags added.
« Last Edit: August 31, 2012, 09:30:41 am by AWOL » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25752
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Now I have connected Pin analog 4 (SDA ) and analog 5 (SDL) to the resepective Two wire interface for the board on the back of the 20 x 4 LCD as well as VCC and GND.
Have you got pullups for the I2C lines?
What value?
Do you have a scope?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Raleigh, NC.
Offline Offline
Full Member
***
Karma: 0
Posts: 129
Addicted to Arduino
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Scope yes.....I did try the pullups with 5K's  and it still didn't work....I just want the LCD to display something.....I don't want my code written for me....am I not using the correct Libraries? I don't know....

simply..SDA and SDL are hooked up from arduino Uno to the I2C interface board behind the LCD...power and gnd are good...

is there any libraries I need beside LiquidCrystal_I2C and wire...

???????

How do I know which address to use as well? I have seen a lot of 0x27 stuff

I was using the LiquidCrystal_I2C lcd( 0x27, 20, 4);

to initiate the LCD...i read how someone wrote you have to also code wire.begin    but that just shows an error.

Damn it man
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25752
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
How do I know which address to use as well? I have seen a lot of 0x27 stuff
Which LCD do you have?
 What does the datasheet say?

5k is a good value for the pullups.

Quote
.i read how someone wrote you have to also code wire.begin    but that just shows an error.
What does that mean, please?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Raleigh, NC.
Offline Offline
Full Member
***
Karma: 0
Posts: 129
Addicted to Arduino
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

sainsmart LCD    HD44780   with the I2C  board on back......

wire library is needed for I2C but I was wondering myself what wire.begin   would do.....
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25752
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I was wondering myself what wire.begin 
I simply cannot imagine.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Raleigh, NC.
Offline Offline
Full Member
***
Karma: 0
Posts: 129
Addicted to Arduino
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

can anybody help me please?  has anyone ever built an arduino I2C lcd project
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 43
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

?

How do I know which address to use as well? I have seen a lot of 0x27 stuff

I was using the LiquidCrystal_I2C lcd( 0x27, 20, 4); to initiate the LCD...


I noticed you also posted in this thread:http://arduino.cc/forum/index.php/topic,119502.15.html
So by now you have already found and used the I2C-scanner found here:http://arduino.cc/playground/Main/I2cScanner
This is the adress you need to put in the declaration.
Logged

Málaga, Spain
Offline Offline
Edison Member
*
Karma: 40
Posts: 2182
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Give the New liquidCrystal library a shot:
https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home

It is reported to work with the Sainsmart LCD. I think at base address 0x27.

Wiring info on corresponding section.
Logged

   

Raleigh, NC.
Offline Offline
Full Member
***
Karma: 0
Posts: 129
Addicted to Arduino
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is a dumb question, I know...but how do I "open the serial monitor"  I uploaded the code for the I2C scanner and it compiled fine...but now what?

I did try the new liquid crystal library but which version are you referring to? There are like 10 downloads on that bitbucket page.....

so confusing....and is this for 1.0 or 1.0.1?

I saw some posts of some sainsmarts getting to work, but dammit I want mine to
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25752
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
how do I "open the serial monitor"
On the Arduino's IDE, the right-most button just above the code pane.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Raleigh, NC.
Offline Offline
Full Member
***
Karma: 0
Posts: 129
Addicted to Arduino
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok I found the serial monitor thing....I have an I2C device at 0x3F  which is cool now I'm getting somewhere...

But I upload my simple code here:   and the LCD backlight just blinks...no characters still....what am I missing??

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x3F,20,4);

void setup()
{
 

lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Hello");
lcd.setCursor(0, 1);
lcd.print("World ");

}


void loop()
{

}
Logged

Málaga, Spain
Offline Offline
Edison Member
*
Karma: 40
Posts: 2182
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This is a dumb question, I know...but how do I "open the serial monitor"  I uploaded the code for the I2C scanner and it compiled fine...but now what?

I did try the new liquid crystal library but which version are you referring to? There are like 10 downloads on that bitbucket page.....

so confusing....and is this for 1.0 or 1.0.1?

I saw some posts of some sainsmarts getting to work, but dammit I want mine to
Get the latest version.

As it says in the wiki:
Quote
To install the library:
* Download the most recent version of the library.
...

version and compatibility:
Quote
== Version ==
Current New LiquidCrystal is the latest zip file in the download section.

The New LiquidCrystal library has been tested and is compatible with Arduino SDK 1.0.1, 1.0 and Arduino SDK 0022.
Logged

   

Raleigh, NC.
Offline Offline
Full Member
***
Karma: 0
Posts: 129
Addicted to Arduino
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Downloaded......installed in place of old library......still doesn't work.....The address my I2C is communicating on is 0x3F.

I upload the code and the LCD just turns off its backlight and flashes from time to time.

Does anyone know some GOOD -verified working test code for the LCD just to say ANYTHING using an I2C connection?
Logged

Raleigh, NC.
Offline Offline
Full Member
***
Karma: 0
Posts: 129
Addicted to Arduino
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am so close I feel it...I just need some new tips....

here is my code:


#include <Wire.h>
#include <LiquidCrystal_I2C.h>




LiquidCrystal_I2C lcd(0x3F, 20, 4);


void setup()
{
 
  lcd.init();
  Wire.begin(0x3F);
  lcd.print("Hello"); 
  lcd.setCursor ( 0, 1 );       
  lcd.print (" World!"); 
  Wire.endTransmission(); 
}

void loop()
{

}



pins 4 and 5 from arduino Uno plugged into I2C board on 20 x 4 LCD...along with ground and power.....just white pixels on LCD still and the LED backlight flashes from time to time.....
Logged

Pages: [1] 2 3 4   Go Up
Jump to: