analog in to 4 bit LCD driver

Try using an external 3.3 volt source for the display and keep all grounds tied together. Depending on the LCD, it may be drawing too much for the 3.3v from the Arduino directly, giving you unstable readings. Although this display is specified to operate at 3.3V, you should still be able to use it with 5VDC if you don't have any other option. And also, you never want to apply/disconnect power to the LCD with data being sent to it over the data lines....could ruin it :wink:

Also, like Anachrocomputer mentioned, (and I would try this first before the other power supply option) you need a contrast pot on pin 3. Hook up around a 10K pot with the outer legs between Pin1 (ground) and Pin2 (VDD) and the center pin of the pot tied to Pin3 (VO). Refer to page 6 of the manual and it shows the connections for the contrast: http://www.sparkfun.com/datasheets/LCD/ADM1602K-NSA-FBS-3.3v.pdf

Okay I got a 10K resistor today, connected it and after I adjusted I can see some stuff, not the actual text that is supposed to be there but I can see all the lower and upper 16 boxes light up. So the contrast is fine at the moment but both the LCD4Bit library or the one came with arduino IDE does not work, I double checked the connections and also tried with a new LCD but still the same.

Any ideas ? I will go insane soon.

If you are seeing all the boxes lit up, then you have the contrast too high. Can you provide a circuit or your code? I can try it on my end and see if I get similar results.
Also, when I first used the LCD4bit library, I couldn't get anything on mine either. I had to make some modifications to the LiquidCrystal library, and then everything worked great. I'll see if I can find what I did to get mine to work, but would be great if you could post your code.

Try looking at this if you haven't already:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1235319100/0

This is the very basic Arduino code that I use with Liquid Crystal, Liquid Crystal seems less complex then lcd4bit and simple so I am just trying with it now:

#include <LiquidCrystal.h>

// LiquidCrystal display with:
// rs on pin 12
// rw on pin 11
// enable on pin 10
// d4, d5, d6, d7 on pins 5, 4, 3, 2
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

void setup()
{
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop()
{
}

And the pin confugration is just same as there as fallows.
I am using it with a XIAMEN 1602K LCD (Amber-Black)

Unfortunately it is 03:42 here now and I am really sleepy, but tomorrow I will take a clear photo of the setup I have so you may have an idea about the general look. And also that will give me an another chance to re-check the cable stuff again.
thanks

tikifare

There seem to be many people having trouble with the LiquidCrystal library, especially in 4-bit mode. I have written a replacement for LiquidCrystal.cpp, the main part of the library. You can find the file and some of my thoughts on why LiquidCrystal doesn't work all the time at http://web.alfredstate.edu/weimandn.

floresta

None of those work. I will go insane.
Tried 2 different Libraries (lcd4Bit and Liquid Crystal, bot the original and the modfied one) with three 3 different LCD's, all 2x16 but different brands and all I can see is the boxes, not a single character.

Try tieing your R/W pin to ground

Well, my first post here, hello everybody.

I managed to have mine work by simply sending lcd.clear() before printing to it.

I read somewhere to tie V0 (Contrast) to GND, this did not work in my case, i had to wire a potentiometer in so I could read anything

I had a similar problem of it not working at all. My problem was that I hadn't changed the LCD4Bit lcd = LCD4Bit(2); to 2 to reflect the fact I had 2 lines! At first I was working under assumption that changing that was optional. Turns out no.

Hope this helps.

I had my LCD display working fine with Arduino Diecimila, in a protoboard.

Now I connected it better, soldering to a shield.

Looks better, but it is not working. Unfortunately, I do not have backup of connections.

Please, when tikifare and others solve the problem, publish a "definitive" connections diagram here, to share.

It is impossible for me continue with my project if I cannot see results!

It is easy to understand tikifare feeling mad with this!

The 1602K LCD screen has a good tech note, but doesn´t work if there is no "official" wiring schem to Arduino.

OldBeaver

this diagram shows how to connect an LCD panel using the example sketch for the LiquidCrystal library.

am i right that there's no way to override the default pin assignments without editing and recompiling the library?

am i right that there's no way to override the default pin assignments without editing and recompiling the library?

no, if you use the Arduino liquid crystal library you can change the pins.

Well as a newbie at this I just spent most of the day working out how to use an LCD. I finally found this site
http://www.skpang.co.uk/content/view/29/42/ and I commend it to you.

If you are here looking for how to do it I would suggest its as good a place as any to start because it gives you photos and data sources. Using the 4bit saves having another 4 wires hanging off your arduino so you can get more sensors on it.

Now I could not get my second line to work until I read here to change the sketch line "LCD4Bit lcd = LCD4Bit(1);"
to
LCD4Bit lcd = LCD4Bit(2);
Otherwise it all comes up on line 1 only.

Thanks to S K Pang, Dubbie and the other posters in this thread
Now to get it to print the Freezer temperature and maybe a page of Murdochs news as well.

Edit: Yes mem and Pluggy are right see later posts .This is an old library and the latest LiquidCrystal library runs as 4 or 8 bits . Go see the photos there though . One picture certainly saves a thousand words on this subject.

Hi tytower, that site uses the old LCD4Bit library which IMO is inferior to the LiquidCrystal library supplied with the latest Arduino release. The Arduino library supports a rich set of print formatting commands that is compatible with the Serial library.

Did you try the latest version of the LiquidCrystal library?

I used the SK Pang site as a basis for my LCD setup. It does use the old 4bit library, but it also works perfectly with the latest LiquidCrystal Library. Grounding the R/W pin seems to make some boards work when they didn't when it was wired to the arduino. The LCD4bit library is slow in comparison to the new LiquidCrystal one.

hi glasspusher
thanks for providing this code

/* Analog in to LCD 4 bits


  • Adapted from the "analog_read_send" and "lcd_8bits" tutorials.
  • This example uses 4 less pins on the Arduino than the 8 bit example.
  • It will take a reading from a 'K' Type thermocouple ice point reference chip
  • on Analog Input 2 and display the temperature in degrees Centigrade on the LCD.
  • One can also set a target temperature for turning a relay off, say for a heater,
  • at a given setpoint temperature. This is done on digital pin 4.
  • These are the pins used on the LCD:
    • DI(register select), RW, DB4..DB7, Enable (7 in total)
  • the pinout for LCD displays is standard and there is plenty
  • of documentation to be found on the internet.
  • 2006, Dave Sopchak glasspusher at outofoptions dot net

*/

int DI = 12; // register select
int RW = 11;
int DB[] = {7, 8, 9, 10};
int Enable = 6;

int temperaturePin = 2; // select the input pin for the temperature
int ledPin = 13; // pin for the LED

void tickleEnable()
{
// send a pulse to enable
digitalWrite(Enable,HIGH);
delayMicroseconds(1); // pause 1 ms according to datasheet
digitalWrite(Enable,LOW);
delayMicroseconds(1); // pause 1 ms according to datasheet
}

void cmdWriteSet()
{
digitalWrite(Enable,LOW);
delayMicroseconds(1); // pause 1 ms according to datasheet
digitalWrite(DI,0);
digitalWrite(RW,0);
}
void LcdCommandWrite(int value)
{
int i = 0;

for (i=DB[3]; i >= DB[0]; i--) // high nybble first
{
digitalWrite(i, value & 128);
value <<= 1;
}
cmdWriteSet();
tickleEnable();

for (i=DB[3]; i >= DB[0]; i--) // low nybble next
{
digitalWrite(i, value & 128);
value <<= 1;
}
cmdWriteSet();
tickleEnable();
}

void LcdDataWrite(int value)
{
int i = 0;

digitalWrite(DI, HIGH);
digitalWrite(RW, LOW);

for (i=DB[3]; i >= DB[0]; i--) // high nybble first
{
digitalWrite(i, value & 128);
value <<= 1;
}
tickleEnable();

for (i=DB[3]; i >= DB[0]; i--) // low nybble next
{
digitalWrite(i, value & 128);
value <<= 1;
}
tickleEnable();
}

void setup (void)
{
int i;
for (i=Enable; i <= DI; i++)
pinMode(i,OUTPUT);

delay(100);
// initiatize lcd after a short pause
// needed by the LCDs controller
LcdCommandWrite(0x28); // function set:
delay(64); // 4-bit interface, 2 display lines, 5x7 font
// other interaces:
// 0x20 = 4 bit, 1 display line

LcdCommandWrite(0x28); // function set:
delay(64); // 4-bit interface, 2 display lines, 5x7 font

LcdCommandWrite(0x06); // entry mode set:
// increment automatically, no display shift
delay(20);
LcdCommandWrite(0x0E); // display control:
// turn display on, cursor on, no blinking
delay(20);
LcdCommandWrite(0x01); // clear display, set cursor position to zero
delay(100);
LcdCommandWrite(0x80); // display control:
// turn display on, cursor on, no blinking
delay(20);
}

void loop (void)
{
int i, val = 0;

for(i = 0; i < 20; ++i)
{
val += analogRead(temperaturePin); // read the value from the sensor
delay(50);
}

val /= 4.06; // conversion value to millivolts

digitalWrite(ledPin, HIGH); // turn the ledPin on
delay(500); // stop the program for some time
digitalWrite(ledPin, LOW); // turn the ledPin off

if(val > 175 * 10) // temperature in deg C times 10, since we're measuring to tenths of a degree
digitalWrite(4,LOW);
else
digitalWrite(4,HIGH);

LcdCommandWrite(0x02); // set cursor position to zero
delay(10);
firstDisplay(val);
}

void firstDisplay(int value)
{
int first,second, third, fourth;

first = value / 1000; //
second = (value - 1000 * first)/ 100;
third = (value - 1000 * first - 100 * second)/ 10;
fourth = (value - 1000 * first - 100 * second - 10 * third);

LcdDataWrite('T');
LcdDataWrite('e');
LcdDataWrite('m');
LcdDataWrite('p');
LcdDataWrite(' ');
LcdDataWrite('=');
LcdDataWrite(' ');

LcdDataWrite(value > 999 ? first + 48 : ' '); // begin onscreen
LcdDataWrite(value > 99 ? second + 48 : ' ');
LcdDataWrite(third + 48);
LcdDataWrite('.');
LcdDataWrite(fourth + 48);

LcdDataWrite(' ');
LcdDataWrite('C');
LcdDataWrite(' ');
LcdDataWrite(' ');
}

...its really helping me alot...
it will be very kind of u, if u also provide the schematic diagram to allow driving an LCD display in 4 bit mode that can display temperature on it and to make this code workable
as i m taking the help frm this code in order to complete my obective that pretty much resemble with urs one....
THanks in Advance

Glasspusher hasn't posted here for a couple of years. Have you looked at the LiquidCrystal library: http://www.arduino.cc/en/Tutorial/LiquidCrystal

The code you posted becomes much simpler if you use that library, here is the firstDisplay function rewritten for the Arduino library:

void firstDisplay(int value)
{
    lcd.print("Temp = ");
    lcd.print(value / 10.0);  // value is in tenths of a degree
    lcd.print(" C");
}

Thanks...Mem ...
my problem is Solved..:slight_smile: