Go Down

Topic: LCD and Serial monitor problem (Read 118 times) previous topic - next topic

Hey all,

I have an arduino mega adk connected with an lcd 16x2.

LCD - ARDUINO MEGA PINS:

1->GND
2->5V
3->GND
4->P30
5->GND
6->P32
11->P34
12->P36
13->P38
14->P40

The sketch is working fine and i see the messages in LCD, but at the moment i open serial monitor (using arduino 1.0.6) my lcd monitor goes crazy with weird symbols.

Any solutions???

Code: [Select]
#include LiquidCrystal.h

// LiquidCrystal lcd(rs, enable, d4, d5, d6, d7);
LiquidCrystal lcd(30, 32, 34, 36, 38, 40);

void setup()
{
lcd.begin(16, 2);
}

void loop()
{
// lcd.setCursor(col, row);
  lcd.setCursor(0,0);
lcd.print("All I want");
delay(1000);
lcd.clear();
lcd.setCursor(0,1);
lcd.print(" to be,");
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("is someone that");
delay(1000);
lcd.clear();
lcd.setCursor(0,1);
lcd.print("makes new things");
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("And thinks");
delay(1000);
lcd.clear();
lcd.setCursor(0,1);
lcd.print("about them.");
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("- John Maeda");
delay(1000);
lcd.clear();
}

maia

dont know if it's help, but i have such behavour with my OLED if I disconnect  GND wire "on fly".

CarlW

Why are you opening the serial monitor?

Your sketch is not printing to the serial monitor.

You could try Serial.begin (your serial monitor speed); in your setup function...


k_motor

Are you opening the serial monitor after the sketch has been running for a while?  Does the arduino reboot when you connect the serial?  If you do that, it will reboot the arduino but not reset the LCD (it still has power right?) -- the result will be bits sent to the LCD out of sequence to what the LCD controller chip is expecting.  Who knows what the arduino could be telling the LCD to do!  If this is the case, the LCD will never recover and will continue to display garbage. 

Somehow you need to open the serial when the arduino is not sending data to the LCD.

#4
Jan 29, 2015, 03:25 pm Last Edit: Jan 29, 2015, 03:38 pm by homealone
Are you opening the serial monitor after the sketch has been running for a while?
Yes.

Does the arduino reboot when you connect the serial?
No.

The arduino works fine!

If you do that, it will reboot the arduino but not reset the LCD (it still has power right?) -- the result will be bits sent to the LCD out of sequence to what the LCD controller chip is expecting.  Who knows what the arduino could be telling the LCD to do!  If this is the case, the LCD will never recover and will continue to display garbage. 
I understand that, but even if i reset the arduino the problem with the LCD remains (yes it still has power).

Somehow you need to open the serial when the arduino is not sending data to the LCD.
I also have a Uno rev3 and with the same cable connection the LCD works fine as long as i dont open the serial monitor! So iam sure its not board problem and it looks farfetched to be coding problem. I guess if the cables are connected ok (as i wrote in first post) then it must be LCD problem.

The only way to temporally fix it is if i close the serial monitor, disconnect and reconnect the usb cable to arduino and then opening the serial monitor.. after 2 or 3 times doing that usually works with both open.


Why are you opening the serial monitor?

Your sketch is not printing to the serial monitor.

You could try Serial.begin (your serial monitor speed); in your setup function...

With this particular sketch i dont need to open the serial monitor but i have the same problem with all my sketches that include LCD. I just put this simple code (that also gives me the error i described) to see if we can pinpoint the problem.

You could try Serial.begin (your serial monitor speed); in your setup function...
Although i think i have already tried that i will do it again to see if things get better.

Thnx for ur feed back both @k_motor, @CarlW.

Any ideas would be very appreciated. 

CarlW

Your serial monitor has a speed that can be adjusted. Use the Serial.begin with that same speed.

When I open my serial monitor; it always resets my arduino sketch. I set up my LCD to reset, if the Arduino reset button is pressed. I'm using a back pack, so it's a little different.

My suggestion is to try a delay (1000); in your set up loop after LCD.begin...


k_motor

Well, I tried to recreate your problem using your example sketch, an arduino UNO, and an LCD, but I couldn't!  The pins I used were:
Code: [Select]
// LiquidCrystal lcd(rs, enable, d4, d5, d6, d7);
LiquidCrystal lcd(9, 8, 7, 6, 5, 4);
  Using those pins, there are no problems with the code you posted, at least on my setup.  My arduino definitely reboots on serial connect but the sketch seems to reinitialize the LCD okay.

CarlW made a good point about a delay in your setup loop.  Definitely worth a try.

I have had garbage output on LCDs in the past when partial instructions get written to the LCD or if I've tried to mess with the LCD timings in the library to write instructions too fast.

Just some other ideas that might or might not help...
Do you have different LCD you could test?  Maybe your LCD controller is slower than what the library expects...
Recheck the wiring?  Faulty connections cause me to tear my hair out more than anything else.

Keep us posted.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy