Go Down

Topic: Change LCD Pins on Mega (Read 3576 times) previous topic - next topic


Hello I have a arduino Mega board that I am using to control my preamp.  I just started learning arduino and programing and need bit of help.  I have a 4x20 LCD HD44780 screen and I want to change the default pin outs on the arduio to run it.  I have heaps of spare pins as Im using a mega.  It wants to run on pins 12, 11, 5, 4, 3, 2. these pins are in use for something else (rotary encoder and pga2310 volume controller)   How do I change the pin outs??

Thank you in advance for your help


Thanks for the fast reply :-D

How Do I change the pin definitions in the LCD library,  I cant find an reference to pin numbers in the LCD lib files.  I tried moving the encoder and it wont work, think its something to do with the way it uses interrupts,  I used the standard encoder code from the playground.  Sorry for all the questions but I am still new to this.  Thanks for your help ? 


Feb 20, 2011, 06:15 am Last Edit: Feb 20, 2011, 06:18 am by retrolefty Reason: 1
If you are using the LiquidCrystal library functions, you just specify the pins you want to use in the initial setup. Here is from a example partial code, (just showing setup function)  file in the library:

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

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);  // here is where you tell it what pins you want to use
void setup() {
 // set up the LCD's number of columns and rows:
 lcd.begin(16, 2);
 // Print a message to the LCD.
 lcd.print("hello, world!");

Here are the what the standard pin numbers are called and the function they perform for the display:

The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)


Thank you so much for your help.  It works great :)

Go Up