Standard LCD 16x2 displays random characters

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
berko
 
Posts: 67
Joined: Sat Aug 04, 2012 6:44 pm

Standard LCD 16x2 displays random characters

Post by berko »

i purchased a Standard LCD 16x2 + extras - white on blue and followed the tutorial examples to get it going and all worked fine: http://learn.adafruit.com/character-lcd ... racter-lcd

Now i have moved on to the next step that i wanted to do which is add a second pot that i can use to scroll through messages.
I connected the pot's center pin to anolog pin A0 and Left to gound, right to 5V both directly on the Arduino Uno.

i have tried powering both from the usb port and a 9V battery.

this works most of the time but sometimes the screen will display random characters (mostly looking like junk but sometimes repeating part of the string to be displayed or the whole string.

is this noise from somewhere? a loose connection? bad code?

let me know if you want pictures. i am doubting it is a solder issue since i had no issues with any of the example scripts.

Code: Select all

// include the library code:
#include <LiquidCrystal.h>

LiquidCrystal lcd(7,8,9,10,11,12);  //to hold the pins of the display
int sensorPin = A0; //pin to read the selection pot
int sensorValue; //to hold the value selected
int currentMessage = 0; //to see if the message has changes since last loop through
String messages[] = {"hello","how are you?","good","me too, thanks!"}; //array of messages

void setup() {
  lcd.begin(16,2);   // set up the LCD's number of columns and rows
  pinMode(sensorPin, INPUT); //set up the pin to read the pot
}

void loop() {
  lcd.setCursor(0,0);
  
  sensorValue = analogRead(sensorPin); //read the pot
  sensorValue = map(sensorValue, 0, 1000, 0, 3); //divide the pot reading into the number of values to match the number of messages
 
 //if statement used to check to see if value changed since last time through.  if true clear old message and set currentMessage value to new message value
  if (currentMessage != sensorValue) {
    currentMessage = sensorValue;
    lcd.clear(); 
  }
  
  lcd.print(messages[sensorValue]);  //print the message to the display
}

User avatar
berko
 
Posts: 67
Joined: Sat Aug 04, 2012 6:44 pm

Re: Standard LCD 16x2 displays random characters

Post by berko »

two more things.
i just added a Serial.println to print the message that should be displayed and when the random characters appear the code is still printing the correct message to the serial monitor.
so i think this may rule out a code issue.
added the following two lines of code. first line as the first line in setup() and the second line as the last line in loop().

Code: Select all


Serial.begin(9600); //first line of setup()

Serial.println(messages[sensorValue]);  //last line of loop()
and the second thing:
if i hit the arduino reset button the message on the LCD goes back to the correct message and the random characters are gone.

User avatar
berko
 
Posts: 67
Joined: Sat Aug 04, 2012 6:44 pm

Re: Standard LCD 16x2 displays random characters

Post by berko »

Image

Image

Image

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Standard LCD 16x2 displays random characters

Post by adafruit_support_bill »

Could be a loose connection or noise. Considering that it is on a breadboard, the first case is the most likely.

Once the display gets out-of-sync, anything you send to it will be garbled until it it re-initialized when you restart the sketch.

RJF
 
Posts: 5
Joined: Mon Jan 07, 2013 4:01 pm

Re: Standard LCD 16x2 displays random characters

Post by RJF »

Exactly same as berko.

Detail:
I recently purchased from you (adafruit conf# 218042) a
Standard LCD 16x2 + extras - white on blue ID: 181

In this regard, seeing same as berko (above) .....apparently.

The LCD is wired and configured per:
http://learn.adafruit.com/character-lcds
Wiring is currently all properly soldered.
All wiring is ~6inch length, 20gauage solid conductors.

All works well ~95% of the time; Arduino Re-Set required to correct.
Suspect strange characters maybe caused by EMI; However,
present setup is at tried & true lab setup.
The system is built on Arduino Mega 2560 R3 and all is being powered by high quality
regulated lab ps (+5V from ps for the LCD).
Simultaneous monitoring of same display data, via pc from RS232 thru 2560, indicates that all data is ok (ie, not corrupt)....
same as previous per berko.

I suggest that the subject LCD is not properly engineered, else
there must be suggested cap power filter, EMI shielding, etc ?
Thank you in advance for any assistance!

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Standard LCD 16x2 displays random characters

Post by adafruit_support_bill »

In my experience, they are somewhat susceptible to noise. I have one (all soldered connections & a regulated supply) that used to have this problem. The source turned out to be a compressor motor on the same lab circuit. Since moving the device to a different circuit I have not had a problem.

RJF
 
Posts: 5
Joined: Mon Jan 07, 2013 4:01 pm

Re: Standard LCD 16x2 displays random characters

Post by RJF »

Any suggested filter circuitry ?
Any code which might be employed to sense if noise characters are being presented on the LCD ?
thx.

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Standard LCD 16x2 displays random characters

Post by adafruit_support_bill »

Filtering noise can be a tricky business. The best solution depends on the nature of the noise and how it is coupling into the system. If you can identify the source and suppress it there that would be ideal. But that is often not possible or practical.

Things you can try are:
  • Bypass caps on power as close to the component as possible.
    Ferrite beads on incoming power & signal lines.
    Shielded cables for signal lines.
    Re-route wires to minimize inductive coupling (keep wires separated and try to cross only at right angles)
    Shielding of the device.
    Move the device to a different circuit.
    Move the device away from the source of noise.

RJF
 
Posts: 5
Joined: Mon Jan 07, 2013 4:01 pm

Re: Standard LCD 16x2 displays random characters

Post by RJF »

Thx.

RJF
 
Posts: 5
Joined: Mon Jan 07, 2013 4:01 pm

Re: Standard LCD 16x2 displays random characters

Post by RJF »

Is there a spec on the maximum wired distance the "Standard LCD 16x2" may be located from the uP (Mega) ?
I've a need for it to be ~12 to 14inches from the uP.
Thx in advance for reply!

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Standard LCD 16x2 displays random characters

Post by adafruit_support_rick »

No spec. But 12-14" shouldn't be a problem, unless you're in a particularly noisy environment.

RJF
 
Posts: 5
Joined: Mon Jan 07, 2013 4:01 pm

Re: Standard LCD 16x2 displays random characters

Post by RJF »

thx db.

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”