Go Down

Topic: LCD shows garbage, usual fixes won't work (Read 1 time) previous topic - next topic

Androxys

Nov 02, 2011, 09:00 pm Last Edit: Nov 02, 2011, 09:17 pm by Androxys Reason: 1
Good evening everyone. I will attach a couple of photos (cellphone camera, not best quality I'm sorry) to better illustrate my problem.

I am using an Arduino Uno with an Everbouquet MC1604B-SYR 16x4 lcd display. However the display shows a lot garbage whenever I press one of the four pushbuttons I'm using (2nd attachment).

I promptly got to investigating, and I saw a lot of people having trouble with either connecting the lcd to the 0/1 RX/TX pins, or having to change some parameters in the serial port (nr. of bits and parity). These have now been taken care of, but the problem persists. The connections and solderings have been checked as well, and all seems good.

The quirky aspect to it though: the arduino works normally UNTIL I press one of the 4 physical buttons I have in my design. When I press one of these 4 buttons (but not all the time, about 50% of the times), the display flips out and starts showing a lot of characters which it wasn't supposed to.

As you can see on the 3rd attachment, I have 4 pushbuttons (red lines), 6 lcd pins (blue lines) and 2 analog sensors attached to analog pins (green lines) - ignore the gray lines, it's a different problem I'm having.

*EDIT*: In another thread I was told that the SPI.h library uses pins 12 and 13 which I am using for two of the buttons. Thought it would be worth to mention that. But the buttons on pins 8 and 9 are also causing the "screen flip out"

Now, some relevant parts of code:

Code: [Select]

void processData(void)
{
.
.
.
 lcd.clear();                
 
 lcd.setCursor (0,0);
 lcd.print("T=");
 lcd.print(temp_str);
 lcd.print((char)223);         // degree symbol
 lcd.print("C");
 
 lcd.setCursor (0,1);
 lcd.print("SetPoint=");
 lcd.print(sp_str);
 
 lcd.setCursor (-4,2);
 lcd.print("pH=");
 lcd.print(ph_str);

 lcd.setCursor (-4,3);
 if (comm_status == 0) {lcd.print("Com:off");}
 if (comm_status == 1) {lcd.print("Com:on");}

 lcd.setCursor (5,3);
 if (valve_status == 0) {lcd.print("Vlv:off");}  
 if (valve_status == 1) {lcd.print("Vlv:on");}
.
.
.
}

void loop(void)
{
.
.
.
 buttonState0 = digitalRead(Calibrate);
 buttonState1 = digitalRead(Up);
 buttonState2 = digitalRead(Down);

 if (buttonState0 == HIGH)
 {
     calibrate_ph7();                                          //run the pH sensor calibration routine
     calibrate_ph4();
 }
 
 if (buttonState1 == HIGH)
 {
     setPoint = setPoint + interval_SetPoint;          //increase the pH setpoint
     delay(200);
 }
 
 if (buttonState2 == HIGH)
 {
     setPoint = setPoint - interval_SetPoint;          //decrease the pH setpoint
     delay(200);
 }
.
.
.
}



Many hours have been put on this and no luck yet, I'm getting a little desperate now. I appreciate any and all help or input that you can provide!

dc42

How exactly are your "4 buttons in" wired?

It may also help to post your code.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Androxys

The buttons are wired exactly as shown here http://www.arduino.cc/en/Tutorial/button. Directly into one digital input each (pins 8, 9, 12, 13). The fact that I was unaware that SPI uses some of those pins, namely 12 and 13, might have something to do with it. Tomorrow at the lab I'll try to change those but I'm pretty sure, if I recall correctly, that the ones on 8 and 9 were also causing trouble.

Have to run to work now, but tomorrow I'll post more of the code. Thank you for the input!

liudr

Maybe this is a reason (in short maybe pin 7 is not good for LCD, try other pins):

http://arduino.cc/forum/index.php/topic,64256.0.html

I have an UNO but I don't have to hook it to an LCD. I just use my shields and serial LCDs I make but I'll give it a try to see how bad it gets.

floresta

I don't understand why you didn't give us all the information up front instead of having us beg you for it.

You have not specified the connections between your LCD module and your Arduino.  We know which pins are used, but for example, which one is used for 'E'?

You have not specified the conditions that cause the processData() function to run.  What triggers it?  How often?

You really shouldn't clear the display unless you have to.  Why rewrite the headings that never change?  If you do clear the display then you don't have to set the cursor to (0,0), it's already there.

Wouldn't it be nice if they actually used the information in lcd.begin()?  Then you wouldn't have to cobble up the offsets on lines 3 and 4.


Don

Go Up