Go Down

Topic: How to change pins on an LCD (Read 2397 times) previous topic - next topic

I am using an Arduino Mega.  I am using a New Haven Display (PN#,  NHD-0216K1Z-NSW-BBW-L) and it use to work but now it does not.  All I did was change the pins and now it does not work.  Same exact code except for the pin change. Here is my new code that does not work.

Code: [Select]


#include <LiquidCrystal.h>

//------------ initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 10, 8, 3, 2);

void setup (){
   lcd.begin(16, 2);                           // LCD is a 16 by 2 character array

   lcd.setCursor(0, 0);
   lcd.print("Manufactured by:"); 
}


My old code used this statement for the initialization.  "LiquidCrystal lcd(2, 8, 9, 10, 11, 12);"  How do I get my LCD to operate using different pins?

Grumpy_Mike

There should be no problem in changing the pins like this.
Are other things using those pins?
Have you wired it up correctly?
Have you blown up any of those pins earlier?

I just checked the upload with another board.  It works with my Mega ADK but not with my Mega 2560.  I will check to see if one of the ports on the 2560 is fried.  I guess I'll just write a quick loop that toggles all those pins at 1Hz and put an LED on each one to see if they are all working.  And yes I am changing the board selection in the tool menu.  Thanks for the quick reply.

floresta

Quote
Here is my new code that does not work.

Where is loop()?  I believe it has to be present, even if it is empty.

Don

jack wp


Quote
now it does not work

Can you explain that? Does it not light up, looks dead, prints wrong characters, or what.
Are you just sending the one string once, or do you have in the loop also to send like ever second?

looks like you are using all the same pins(just rearranged), except pin 3 in now used, but wasn't before.
Good luck, Jack

The backlight lights up.  I can see blocks on the display so that part is getting power also.  The blocks fade in and out when I adjust the POT connected for the contrast.  I just checked all my pins with a scope and they are outputting signals.  I works on my ADK Mega but not my Mega 2560.

jack wp

I didn't see a url to the LCD. One may be helpful.
Is it a shield (plugging it on top of the arduino), or are you running wires between?
So the code, and LCD works one one arduino, but not the other?  Hmmm
Good luck, Jack

floresta

Quote
My old code used this statement for the initialization.  "LiquidCrystal lcd(2, 8, 9, 10, 11, 12);"  How do I get my LCD to operate using different pins?


Until you provide us with a picture or an accurate description of the interconnections between your LCD and your Arduino we cannot tell if you understand the significance of the numbers within the parentheses, specifically the significance of the order in which the numbers appear.

Of course it doesn't help that the author of the sketch, and the author of the example upon which it is based didn't explain this either.  I think this is a bit more informative:

Code: [Select]

//LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);      // put your pin numbers here



Don

Attached is my snippet of my schematic connection for the LCD.
Here is the code for pin setup.

//LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
LiquidCrystal lcd(12, 11, 10, 8, 3, 2 );

Here is the link to the display.
http://www.mouser.com/ProductDetail/Newhaven-Display/NHD-0216K1Z-NSW-BBW-L/?qs=%2fha2pyFadujEgI3vbt6cm6Rm57Vr1NYnKeJ6ExmoEz%2fA8J9l88fazv79zjdzYbxt

jack wp

It appears the wiring is correct.
You say it works with one arduion, but not with the other. Is that running the arduion boards with only the display , or does one have other peripherals attached?
When It does not work, what does it actually do/not do?

At this point, looks like the LCD is good. Looks like your sketch is good. Looks like your wiring is good., and at least one arduino board is good. It is getting narrowed down now. Did you get the pins checked on the questionable arduino board yet?
Good luck, Jack

floresta

From your original post -->  "All I did was change the pins and now it does not work."

Have you tried going back to the original configuration to see if it still works as it did before?

Don

The old config seems to not work with the Mega 2560 also.  I checked all the pin (D0-D13) with a 1 Hz pulse programs.  All the pins flashed the LED/resistor that I put on them.  Pins seem to be fine.  Th ADK Mega works and the Mega 2560 does not.  I have no clue why.

jack wp

#12
Aug 04, 2013, 06:10 pm Last Edit: Aug 04, 2013, 06:17 pm by jackwp Reason: 1
Is that running the arduion boards with only the display , or does one have other peripherals attached?

Add the loop() function, and have it also send info to the lcd, ever so often (one second maybe).
Good luck, Jack

floresta

Quote
Add the loop() function, and have it also send info to the lcd, ever so often (one second maybe).

I disagree.  If you can't get the display to work with static information then sending it stuff over and over again will only make the troubleshooting harder.

So far we have only seen program fragments and a diagram of how he intends to connect the display.  In order to provide decent help we have to see the actual circuit connections, the actual code used (all of it) with those connections, and the actual resulting display.

Don



jack wp

I think the OP gave us his complete sketch in his first post, and it did not include a loop() function. It may not be the problem, but I see that some boards/systems, really do want the loop() to be there (even if empty). I was hoping he could add the loop(), and put in two or three lines to make the display continue to work.
Can't hurt.

I think he also provided us the exact wiring diagram he is using (posted early today). It looked correct to me.

Still a mystery, but not for long (I hope). LOL
Good luck, Jack

Go Up