Seemingly Random Characters

Hi All,

I am following the lcd tutorial here:
http://www.hacktronics.com/Tutorials/arduino-character-lcd-tutorial.html

I was getting a lit blue screen only from another tutorial now the backlight is on but with random characters instead of the Hello World message.
The code compiles and uploads and I used the serial monitor to see if all code being executed and it is.
I am new to Arduino although a (veteran) electrician and understand the basics.
The lcd and all other stuff is from the Arduino Starter Kit and I am using Sublime Text2 with this (GitHub - Robot-Will/Stino: A Sublime Text Plugin for Arduino) plugin.

Any insight would be great.
Thanks

Jim

We need pictures. In order to see the "random characters". Are they the same every time you turn it on?

Pictures must be perfectly focused, and in good light. Show clearly your wiring.

And an actual copy of your code, in "code tags" (if unsure what that is, read the instructions) within your posting, not an attachment.

Firstly,
Thanks for the reply.
My sketch code below and below that some images of the arduino and lcd.
If I disconnect power through the usb and reconnect I get a different set of characters.
Pin 13 and 3 I put through 220ohm resistors.

//Here is the driver code:
/* ------------------------------------------------------------------------------- */
// character LCD example code
// www.hacktronics.com


// Connections:
// rs (LCD pin 4) to Arduino pin 12
// rw (LCD pin 5) to Arduino pin 11
// enable (LCD pin 6) to Arduino pin 10
// LCD pin 15 to Arduino pin 13
// LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2

#include <LiquidCrystal.h>

LiquidCrystal lcd (12, 11, 10, 5, 4, 3, 2);


int backLight = 13;    // pin 13 will control the backlight

void setup()
{

  Serial.begin(9600);	
  pinMode(backLight, OUTPUT);
  digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
  Serial.println("Set Backlight");
  lcd.begin(16,2);              // columns, rows.  use 16,2 for a 16x2 LCD, etc.
  //lcd.clear(); 
  Serial.println("Set LCD to clear");                 // start with a blank screen
  lcd.setCursor(0,0); 
  Serial.println("Set Cursor to 0,0");          // set cursor to column 0, row 0 (the first row)
  lcd.print("Hello, World"); 
  Serial.println("Set Hello World");   // change this text to whatever you like. keep it clean.
  lcd.setCursor(0,1);           // set cursor to column 0, row 1
  lcd.print("We are printing line 2");
  //lcd.clear(); 
  
  // if you have a 4 row LCD, uncomment these lines to write to the bottom rows
  // and change the lcd.begin() statement above.
  //lcd.setCursor(0,2);         // set cursor to column 0, row 2
  //lcd.print("Row 3");
  //lcd.setCursor(0,3);         // set cursor to column 0, row 3
  //lcd.print("Row 4");
}

void loop()
{
	//lcd.clear(); 
}
/* ------------------------------------------------------------------------------- */

photo 1.JPG

photo 2.JPG

photo 3.JPG

photo 4.JPG

photo 5.JPG

I use a different pinout for the LCD but your code works for me. I'd suggest you really check all the data lines to be sure they are in the right order and correctly wired.

Pete

I think you have two of the data wires the wrong way round. On the Arduino (image 1) you appear to have 2 Brown 3 Green 4 Mauve 5 Blue but in image 3 the wires from left to right are Brown Green Blue Mauve

switch the blue and mauve around on the LCD.

Pete

Hi Pete,

Thats it!

Thanks very much, I'm off to look for an article that explains the pin functionality and then see if I can write my own sketch. Have a good weekend.

JIm

Harpertooned: Pin 13 and 3 I put through 220ohm resistors.

I doubt it would cause any malfunction, but why on earth would you do that? :astonished:

Paul,

int backLight = 13; // pin 13 will control the backlight

It occurred to me that it may have been a back-light washing out the text issue during my first attempt and so I thought I would drop the voltage over the resistor to attempt to dim the light.

On pin 3 that 220ohm resistor i think was an error of judgement. The text shows the same with or without it.

What I found a bit unusual, and I'm sure there is a good reason for it, is that on the back of the lcd it shows the pins 1-16 left to right but also shows a number 16 on the left of the pins and a number 1 on the right confusingly.

Paul__B: I doubt it would cause any malfunction, but why on earth would you do that? :astonished:

His reasoning is OK. The resistor on pin 13 is current limiting for the LED which may not be needed but too much resistance is better than too little.

The resistor on pin 3 goes to GND if he followed the photo in the tutorial. It is the replacement for the potentiometer that you so frequently recommend.

Don

Harpertooned: . . . On pin 3 that 220ohm resistor i think was an error of judgement. The text shows the same with or without it.

If you just removed the resistor and left pin 3 open then your display should be blank. If you removed the resistor and connected pin 3 to GND you should see a display although it may be darker than optimum. If you have a readable display then leave it alone for now and tinker with the contrast later after you get any other problems resolved.

What I found a bit unusual, and I'm sure there is a good reason for it, is that on the back of the lcd it shows the pins 1-16 left to right but also shows a number 16 on the left of the pins and a number 1 on the right confusingly.

If your display has the row of pins at the upper left of the pc board then pin 1 will be near the edge of the board and pin 16 will closer to the center of the board.

Displays with the pins at the lower left of the pc board are a different story as there seems to be no standard system for the pinout. What configuration do you have?

EDIT: I just remembered to look at the photos. You have a 'normal' display. Just remember that pin 1 is near the edge and pin 16 is near the center.

Check your data wires. You may have data wires swapped. I'll see if I can verify that from your photos.

Don

I have looked at the photos and agree with what was posted in reply #4. You have D4 and D5 reversed. Did you happen to notice how neatly the wires were arranged in that tutorial?

Don

d1e477aeab5ff1f568e98931eb73790dd0389b52.jpg 13d077e2d967f00af5032c05ec1d7de5b817764c.jpg

09eb3ef2d9fc4463a4e830951742a886a5222558.jpg f41a2c12698ab01381ccb78d3c76c8e4a20d0537.jpg

9934840b54a30276da962fe117857fa8722dd254.jpg

Those photos are dreadful! (And posted as attachments instead of in-line links. Makes things difficult with this current (per)version of the forum software.)

OK now,

Harpertooned:
int backLight = 13; // pin 13 will control the backlight

It occurred to me that it may have been a back-light washing out the text issue during my first attempt and so I thought I would drop the voltage over the resistor to attempt to dim the light.

Well, that is simply not going to happen. You cannot “wash out” the LCD display with the backlight.

Harpertooned:
On pin 3 that 220ohm resistor I think was an error of judgement. The text shows the same with or without it.

Well, no. This is the contrast resistor - the best value will generally be between zero and 1k but clearly the text is perfectly visible as things are. There may be little difference between zero and 220 ohms but one will be better than the other.

Harpertooned:
What I found a bit unusual, and I’m sure there is a good reason for it, is that on the back of the LCD it shows the pins 1-16 left to right but also shows a number 16 on the left of the pins and a number 1 on the right confusingly.

Looks perfectly correct to me. I think you were getting confused. Pin 1 is nearest the end of the board.

floresta:
His reasoning is OK. The resistor on pin 13 is current limiting for the LED which may not be needed but too much resistance is better than too little.

It is indeed not needed - if we could only see R8, I am quite sure we would observe it marked as “101”. It seems Harpertooned actually realised that already as well as:

floresta:
The resistor on pin 3 goes to GND if he followed the photo in the tutorial. It is the replacement for the potentiometer that you so frequently recommend.

He got that right! The other problem was the confusion of Pin 3 on the LCD being Vo, the contrast voltage, and pin 13 on the Arduino which was actually connected to pin 15 on the LCD.

floresta:
I have looked at the photos and agree with what was posted in reply #4. You have D4 and D5 reversed. Did you happen to notice how neatly the wires were arranged in that tutorial?

Well, got that sorted. But following the wires in those terrible photos was mind-bending or eye-crossing.

In terms of neat wiring, what he needs to do is to get some more of those “Dupont” male-to-female wires and rather than separating them all, break out some groups including the the black-brown-red as three, some other groups of three, four and five, then get some of the two, three, four and five-way housings from eBay - generally only a dollar or two per hundred so you can afford to get ridiculous quantities - and make up nice little ribbons for connections.

Generally you will want the wires in order, but you may also want certain transpositions for particular applications. The single housings can be removed intact with reasonable care (and the smallest jeweller’s screwdriver in the set) and saved for potential re-use.

If you separate the black-brown-red or black-brown-red-orange then you can have the black and red in a two-pin housing and the brown as a single (or brown and orange as singles) If you simply swap red and brown in a three pin housing you have of course, a “standard” servo or sensor cable (though what is usually used for servos is brown-red-orange as it is not necessary to perform the swap; the brown becomes the ground).