Hi everybody, this is my first post.
Well, could you tell us what the problem you're having is?.. :
jejeje I am trying but I do not know how to insert a post with HTML
Then don't? Just describe it in text, please.
Dear all,
I am noobie with Arduino and I am trying to make a "Hello world" into a 8x2 HD44780 LCD (http://www.seeedstudio.com/depot/lcd-82-characters-blue-back-light-p-120.html), but I do not get anything else than a blue light in the display. There is nothing in the display and playing with Vo between GND and 5V does not help.
Any contribution will be really appreciated.
Thanks in advance
Attached there is a photo with the wiring and another one showing the display and the schema of the wiring.
This is my "Hello world" program:
#include <LiquidCrystal.h>
//8 bit: RS, RW, EN, D0, D1, D2, D3, D4, D5, D6, D7
//RS-->PC0
//RW-->PC1
//EN-->PC2
LiquidCrystal lcd(14, 15, 16, 8, 9, 10, 11, 4, 5, 6, 7);
void setup()
{
}
void loop()
{
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("hello");
lcd.setCursor(0,1);
lcd.print("world!");
}
and this is my LiquidCrystal.cpp (from Arduino 17, not from SeeedStudio
#include <LiquidCrystal&>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include "WProgram.h"
// When the display powers up, it is configured as follows:
//
// 1. Display clear
// 2. Function set:
// DL = 1; 8-bit interface data
// N = 0; 1-line display
// F = 0; 5x8 dot character font
// 3. Display on/off control:
// D = 0; Display off
// C = 0; Cursor off
// B = 0; Blinking off
// 4. Entry mode set:
// I/D = 1; Increment by 1
// S = 0; No shift
//
// Note, however, that resetting the Arduino doesn't reset the LCD, so we
// can't assume that its in that state when a sketch starts (and the
// LiquidCrystal constructor is called).
LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7)
{
init(0, rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7);
}
LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7)
{
init(0, rs, -1, enable, d0, d1, d2, d3, d4, d5, d6, d7);
}
LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3)
{
init(1, rs, rw, enable, d0, d1, d2, d3, 0, 0, 0, 0);
}
LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3)
{
init(1, rs, -1, enable, d0, d1, d2, d3, 0, 0, 0, 0);
}
void LiquidCrystal::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7)
{
_rs_pin = rs;
_rw_pin = rw;
_enable_pin = enable;
_data_pins[0] = d0;
_data_pins[1] = d1;
_data_pins[2] = d2;
_data_pins[3] = d3;
_data_pins[4] = d4;
_data_pins[5] = d5;
_data_pins[6] = d6;
_data_pins[7] = d7;
pinMode(_rs_pin, OUTPUT);
// we can save 1 pin by not using RW. Indicate by passing -1 instead of pin#
if (_rw_pin != -1) {
pinMode(_rw_pin, OUTPUT);
}
pinMode(_enable_pin, OUTPUT);
if (fourbitmode)
_displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS;
else
_displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS;
// begin(16, 1);
begin(8, 2);
}
void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
if (lines > 1) {
_displayfunction |= LCD_2LINE;
}
_numlines = lines;
_currline = 0;
// for some 1 line displays you can select a 10 pixel high font
if ((dotsize != 0) && (lines == 1)) {
_displayfunction |= LCD_5x10DOTS;
}
// SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!
// according to datasheet, we need at least 40ms after power rises above 2.7V
// before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50
delayMicroseconds(50000);
// Now we pull both RS and R/W low to begin commands
digitalWrite(_rs_pin, LOW);
digitalWrite(_enable_pin, LOW);
if (_rw_pin != -1) {
digitalWrite(_rw_pin, LOW);
}
//put the LCD into 4 bit or 8 bit mode
if (! (_displayfunction & LCD_8BITMODE)) {
// this is according to the hitachi HD44780 datasheet
// figure 24, pg 46
// we start in 8bit mode, try to set 4 bit mode
write4bits(0x03);
delayMicroseconds(4500); // wait min 4.1ms
// second try
write4bits(0x03);
delayMicroseconds(4500); // wait min 4.1ms
// third go!
write4bits(0x03);
delayMicroseconds(150);
// finally, set to 8-bit interface
write4bits(0x02);
} else {
// this is according to the hitachi HD44780 datasheet
// page 45 figure 23
// Send function set command sequence
command(LCD_FUNCTIONSET | _displayfunction);
delayMicroseconds(4500); // wait more than 4.1ms
// second try
command(LCD_FUNCTIONSET | _displayfunction);
delayMicroseconds(150);
// third go
command(LCD_FUNCTIONSET | _displayfunction);
}
// finally, set # lines, font size, etc.
command(LCD_FUNCTIONSET | _displayfunction);
// turn the display on with no cursor or blinking default
_displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;
display();
// clear it off
clear();
// Initialize to default text direction (for romance languages)
_displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;
// set the entry mode
command(LCD_ENTRYMODESET | _displaymode);
}
/* high level commands, for the user! */
void LiquidCrystal::clear()
{
command(LCD_CLEARDISPLAY); // clear display, set cursor position to zero
delayMicroseconds(2000); // this command takes a long time!
}
void LiquidCrystal::setCursor(uint8_t col, uint8_t row)
{
int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
if ( row > _numlines ) {
row = _numlines-1; // we count rows starting w/0
}
command(LCD_SETDDRAMADDR | (col + row_offsets[row]));
}
/* mid level commands, for sending data/cmds */
inline void LiquidCrystal::command(uint8_t value) {
send(value, LOW);
}
inline void LiquidCrystal::write(uint8_t value) {
send(value, HIGH);
}
/* low level data pushing commands */
// write either command or data, with automatic 4/8-bit selection
void LiquidCrystal::send(uint8_t value, uint8_t mode) {
digitalWrite(_rs_pin, mode);
// if there is a RW pin indicated, set it low to Write
if (_rw_pin != -1) {
digitalWrite(_rw_pin, LOW);
}
if (_displayfunction & LCD_8BITMODE) { write8bits(value);
} else {
write4bits(value>>4);
write4bits(value);
}
}
void LiquidCrystal::write4bits(uint8_t value) {
for (int i = 0; i < 4; i++) {
pinMode(_data_pins[i], OUTPUT);
digitalWrite(_data_pins[i], (value >> i) & 0x01);
}
pulseEnable();
}
void LiquidCrystal::write8bits(uint8_t value) {
for (int i = 0; i < 8; i++) {
pinMode(_data_pins[i], OUTPUT);
digitalWrite(_data_pins[i], (value >> i) & 0x01);
}
pulseEnable();
}
The attachments:
Make life easy on yourself and make a 4bit connection to the board. You have 11 connections, it can be done with 6. At least your sketch is set for 11 pins, your wiring is for 10 which may be part of the problem. Its generally a good idea to wire the backlight via a resistor unless it has an internal one.
This is for a 16*2 display but it will give you the idea :
http://www.skpang.co.uk/content/view/29/42/
It uses the old 4bit library but it will work fine with the present liquidcrystal library as well.
galtanegra:
Your program code for the LCD should be in setup(), not in loop(). The loop() function should be empty.
Also - I don't see the lcd.begin() statement which, if omitted will leave you with the LCD initialized as a 1 line display. On the other hand it looks like you have cobbled up LiquidCrystal.cpp to handle this which is NOT a good idea.
Fix up your program code, restore LiquidCrystal.cpp to its original form, and report back with your results. A better picture of your inter-connections would also help.
Don
Hi,
thanks for your answers. I have redone the connections in 4 bit mode and also put a resistor at the backlight as you comment. Now the sketch is as follows:
DISPLAY ARDUINO
======= =======
1 - GND GND
2 - Vdd 5V
3 - Vo Between GND and 5V (5k variable resistor)
4 - RS 12
5 - R/W GND
6 - E 11
11 - DB4 5
12 - DB5 4
13 - DB6 3
14 - DB7 2
15 - LEDA 5V through a 1K5 resistor
16 - LEDK GND
I have changed the code of my "Hello world" according to the new sketch. I have also added a lcd.begin(8,2) to set the display of 8 characters and two lines. This was done before inside LiquidCrystal.cpp but now I have recover the original LiquidCrystal.
Also the code is now in setup().
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
{
lcd.begin(8,2);
delay(1000);
lcd.print("HELLO");
}
void loop()
{
}
This is a photo of the actual wiring. My apologies if it is not very clear.
Sadly the behavior is the same, the only signal of life in the display is the backlight.
Any comments or suggestions will be really appreciated as I am completely stucked with this.
Thank you !
galtanegra:
OK - now, does your contrast control work properly? All you need for this test are the connections to pins 1, 2 and 3 (and the backlight) although the others shouldn't hurt. At one end of the potentiometer rotation your screen should be blank. At the other end you should have black boxes on the upper row. The correct setting is usually near where the single row of black boxes is barely visible. If you can't get this to work as described there is no sense going any further.
Don't forget to connect pin 5 (R/W) of the LCD display to ground.
Your backlight seems very bright.
Don
Hi Don,
I have done this test with just the connections on pins 1, 2, 3 and backlight (15 and 16).
Playing with the potentiometer does not make nothing, screen is always blank, never see black boxes.
Nothing happens neither if I connect pin 3 directly to GND or 5V.
I have increased the resistor of the backlight to 5K and now it looks not so brilliant.
I have also recheck the connection on pin 3 looking for a shortcircuit but it looks pretty well.
Any idea?
Thanks,
Carlos
galtanegra:
Make sure that you have not confused pins 1 and 2 with pins 15 and 16. The drawing on the datasheet appears to be a top view. The PC board probably has some way of identifying pin 1 so you will have to check it and make sure that you haven't wired the board from the wrong end.
[EDIT] I just looked at the photos on the Seeedstudio website and the pins are clearly identified. Make sure that your wiring agrees with the pdf datasheet, don't use the Vss and Vdd pin designations on the awful drawing below the PC board photos (see below).
If you are going to test things without the potentiometer then you want to connect pin 3 to ground, not +5v. The drawing on the seeedstudio page, which is for an LCD with inline pins, shows the contrast pin grounded but it also shows pin 1 as +5v and pin 2 as ground which is backwards from all of the LCD modules that I have seen. Perhaps yours is different as well.
I question the 5K resistor value for the backlight. It seems high by one or two orders of magnitude. Even with no voltage drop across the LED this would result in only 1mA of current which won't light any LED that I have ever seen.
Don
Hi Don,
the board is clearly labelled as shown in the following picture:
the connections agree with the seeedstudio pdf datasheet and I had already noticed that the connections for Vss and Vdd in the awful drawing were wrong.
I keep the potentiometer for Vo in the tests, I was just trying to see any change if I was bypassing it and going to the extreme values for Vo (GND and 5V). I think it is very strange that nothing happens in the display. In one post I read that some displays need a Vo below GND, could this be the case? If so, do I need to make a test with a polarity inverter? which would be the best way to implement that?
You are right with the resistor for the backlight. I was using a 660 ohm. Using a 5K the LED is almost unlit. Now I have left 1K and it looks ok.
Thanks for your interest, if you think I can test whatever please do not hesitate to tell me
Carlos
In one post I read that some displays need a Vo below GND, could this be the case?
It is not likely in the case of this display. The data sheet would show this requirement in the 'LCD Driving Voltage' specification.
The website shows the connections for an in-line (1x16) connector while the actual display has a two row connector (2x8). The website also shows the Vdd and Vss polarities incorrectly. So you had to make your original connections by interpreting the data sheet against an inappropriate AND incorrect diagram. It is possible that you did not notice the reversed Vss - Vdd connections until after you had connected them incorrectly the first time.
It seems to me that seeedstudio should provide you with a new display and fix their website.
Don
Hi Don,
I would bet the display is simply dead. I have bought another one, this time a 16x2 Powertype and it is working fine. So I will follow your advice and I will sent it back to the customer.
Thank you very much for your help
Carlos
I got a dead one on my first try.