LCD and arduino software problem

I am getting some weird things from an .... actually three LCD's.
I have checked the wiring over and over again.

It will display what ever I sent it. But the line I sent is then followed by two odd random looking "characters".
They ONLY seem to change after a re-write of the arduino software.
This is like.. the 10294501 time I have had trouble with this software.. It seems really buggy.
Although... I did notice It seemed to be buggy once I installed the Atmel software for the mkII.

Character one
{
They are
Full row on
nothing on
full row on
first pixel on nothing else
nothing on
all on except first pixel
}
Now it looks now that they are just completely random at this point.
The code is SO simple I can't see how there could be a problem.
But feel free to check it out:

#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 4, 7, 8, 11, 12);
void setup() {
  lcd.begin(16, 2);
  lcd.println("Hello World...");
}
void loop() {
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(100);
}

EDIT:
That's interesting...
I just ... Wow.. okay.
Sorry it just boggling me why this would do this.

I changed the it from print line to print.
It showed no weird characters.
Amazed I changed it back and rewrote to the arduino.
The weird symbols came back.
I repeated this process a couple of times.

Uhm.. Help?

EDIT2: =O
If I use the new line command "\n" It shows one of those weird symbols again! It's the return or next line that is the problem!

There are a couple of things in the code: make sure you are wired the way it's setup.

Since you are now starting, take a look at this link, wire your LCD the same way to confirm everything works. and check the lcd.println() command - you might wish to drop the return.

Ken H>

The wiring is fine dude.
The code is fine to, as long as I use print, which if you look at the library I'm not sure println is supported but, I thought it was.
Not sure, it might have just been all this java programming I have been doing in school...

I know the pin numbers do look scattered, but it's for a reason.
I changed 11 and 12 for testing. They where originally 12, 13.
Which if you look at the arduino duemilanove that saves all pwm pins free. (for other uses) because this setup is being used in a controller.

Doing println i should imagine your getting a line feed and carriage return at the end, 0x0A and 0x0D :slight_smile:

Vampist:

The code is SO simple I can't see how there could be a problem.

You are referring to the part of the code that you wrote. The LiquidCrystal library code is a lot more complicated. The underlying Arduino code is even more complicated than that. There are more layers beyond the Arduino, but you should get the point.

I think that 'beige' has identified the source of your two extraneous characters. You should understand that these LCDs were never meant to emulate a terminal. They do not respond as you might expect to the non-printable ASCII codes. I believe that some of the Serial LCD implementations attempt to do some of this, but that is done by another processor with more code between the Arduino and the LCD controller.

Don

@don Of course I meant the code I wrote.. What else would I mean? :-?
I appreciate the post but, if you were just going to scold me why did you post?

@beige: Are these not programmed (or allowed) into the liquid crystal library?

vampist:

Sorry - I wasn't trying scold or criticize you in any way. I was just trying to point out why you can't evaluate the action of the Arduino solely based on the code that you wrote. You have to take into consideration that fact that you are using a lot of code that was written by others who don't necessarily think along the same lines as you do. You are also dealing with an LCD controller that isn't controlled in the same manner that other display devices are.

Are these not programmed (or allowed) into the liquid crystal library?

Correct.

The non-printable ASCII codes (those below 0x20) are not programmed or allowed into the LiquidCrystal library because they are not understood by the controller in the LCD module. The LiquidCrystal library is just the interface between you and the controller in the LCD module. Without the addition of a lot more code it is limited in what it can do by what the LCD controller 'understands'.

The problem with incorporating such code is that each LCD configuration must be dealt with differently. It's certainly not impossible, its just complicated.

Don

The non-printable ASCII codes (those below 0x20) are not programmed or allowed into the LiquidCrystal library because they are not understood by the controller in the LCD module.

I think this should be explained differently.

It's not that those codes are not allowed, but they are not interpreted or filtered. The LiquidCrystal library just passes them along to the LCD controller which then doesn't know what to do with them.

Don

Ooooh okay. Sorry about the misunderstanding there.

Thanks for the information, that explains it all really.

Although now working further into my controller I have found another problem..

I am building my own arduino like setup on a solder breadboard.
I only have the basics on the board.
7805 voltage reg, ATmega328p-pu, 16MHz crystal, and the required 22pF and 10uF capacitors.

Which was built following instructions here: http://itp.nyu.edu/physcomp/Tutorials/ArduinoBreadboard#toc2

Now, here is the problem. When I put code in that uses "analogRead()" the LCD stops working..

Is this something to do with the pins floating or not floating? Which is stopping the code from moving on? This is really puzzling me.

#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 4, 7, 8, 12, 13);
int start = 0;
void startup() {
  lcd.clear();
  lcd.print("********************");
  lcd.setCursor(0, 1);
  lcd.print("*");
  lcd.setCursor(19, 1);
  lcd.print("*");
  lcd.setCursor(0, 2);
  lcd.print("*");
  lcd.setCursor(19, 2);
  lcd.print("*");
  lcd.setCursor(0, 3);
  lcd.print("********************");
  lcd.setCursor(6, 1);
  lcd.print("Wireless");
  lcd.setCursor(8, 2);
  lcd.print("V 0.1");
  start++;
  delay(3000);
  lcd.clear();
}
void setup() {
  lcd.begin(20, 4);
}
void loop() {
  if (start == 0){startup();}
  int x_ax = analogRead(0);
  int y_ax = analogRead(1);
  lcd.setCursor(0, 0);
  if(x_ax <= 504) {lcd.print("R");}
  if(x_ax == 507) {lcd.print("N");}
  if(x_ax >= 510) {lcd.print("F");}
}

vampist,

I put your code into my Arduino and hooked up a potentiometer to analog0 and it worked just fine. I only had to change the pins used by the LCD to match my setup. When I would turn the pot from one side to the other, the display would change from F to R and back.

I never saw the N so I altered the code slightly in that area to the following and I get all three readings now.

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int start = 0;
void startup() {
  lcd.clear();
  lcd.print("********************");
  lcd.setCursor(0, 1);
  lcd.print("*");
  lcd.setCursor(19, 1);
  lcd.print("*");
  lcd.setCursor(0, 2);
  lcd.print("*");
  lcd.setCursor(19, 2);
  lcd.print("*");
  lcd.setCursor(0, 3);
  lcd.print("********************");
  lcd.setCursor(6, 1);
  lcd.print("Wireless");
  lcd.setCursor(8, 2);
  lcd.print("V 0.1");
  start++;
  delay(3000);
  lcd.clear();
}
void setup() {
  lcd.begin(20, 4);
}
void loop() {
  if (start == 0){startup();}
  int x_ax = analogRead(0);
  int y_ax = analogRead(1);
  lcd.setCursor(0, 0);
  if(x_ax <= 490) {lcd.print("R");}
  if(x_ax > 491 and x_ax < 510) {lcd.print("N");}
  if(x_ax >= 511) {lcd.print("F");}
}

Not sure what is not working for you, but it seems fine the way it is written. The only thing might be the way you have your breadboarded arduino clone wired might be causing the problems for you.

Hope this helps at least a little bit. :-/

Dan

Why are you trying to analogRead form pins 0 and 1? Are you trying to receive a random number? You may want to use the serial monitor to see what values your getting from the analogRead so you can get the code to do what you want it too.

@Photo-worx Yeah I don't know. It works on my arduino also.

The reason for 504, 507, 510; is because the pot on the joystick "rests" at 507, so I just went a few off in each direction.

Remember it's not a complete clone. Only the basics are in place.

@digimike ah... What? I am use analogRead() to see what the current integer value of a particular potentiometer is.

You can still use the same numbers you have, but by using the and in your if statement you get a range in case the joystick varies at all at rest.

  if(x_ax <= 504) {lcd.print("R");}
  if(x_ax > 504 and x_ax < 510) {lcd.print("N");}
  if(x_ax >= 510) {lcd.print("F");}

It just gives you a little play in the code for joystick slop. :wink:

I know what you mean, I planned on doing this with the y_ax because it doesn't rest at the same.

But, I am not just doing a plain old forward and reverse type controller.
I would have bought a couple of buttons if that was the case.

I plan on using map()

But does anyone know if there is something that allows the use of analog on the ATmega328? or if the bootloader does something with them when starting up?

It's the only thing I can think of.. Why else would the lcd display stop working when I add analogRead()?

vampist:

I only have the basics on the board...

The link you refer to does not mention a bypass capacitor for the ATmega Vcc pin so I assume that you didn't use one either. It's a long shot as far as your strange program behavior goes, but it really should be there anyway.

Don

Bypass capacitor for Vcc?
Size and type?
(take note I need to read up more on capacitors)

vampist:

Bypass capacitor for Vcc

That would be a really good search phrase for Google. The first hit gives a good explanation. You might also search for the schematic diagram for the Arduino, the Boarduino, the Bare Bones Board or any of the other variants that are out there.

Don

Hm, very interesting. So it reduces the "ripples" or AC in a DC circuit.
I can definitely see how this may cause a bad affect in an IC.

Would you as well suggest .1uF?

vampist:

Would you as well suggest .1uF

That's typically what is used. Put it as close to the IC as possible.

Don