Using different pins for LCD?

I want to you use something like a DFRobot LCD Keypad Shield for Arduino but I have used a lot of the pins that it calls out. Can I just change them to other ones?

I’m using several pins already and I need 3 more for optical limit switches. This is what I already have called out in my program.

#define EN1_PIN 3 // Set up for Main Stepper
#define foodPumpMotorPin 4 //Turn on 110 AC for peristaltic pump 1 (might be upgraded to Stepper)
#define waterPumpMotorPin 5 //Turn on 110 AC for peristaltic pump 2
#define ledPin 7 // For LED on Motor Two board
#define motorPin1 8 // Set up for Stepper 2
#define motorPin2 9 // Set up for Stepper 2
#define EN2_PIN 11 // Set up for Main Stepper
#define DIR1_PIN 12 // Set up for Main Stepper
#define DIR2_PIN 13 // Set up for Main Stepper

I have an Arduino Mega 2560

  1. The Main Stepper is driven by a Rugged Shield and their code calls out pins 3, 11, 12 and 13. (purchased and working will)
  2. The Stepper 2 pins 8 and 9 along with pin 7 for the LED, are from code for the YourDuino 5V stepper motor + stepper motor driver board. (not yet purchased but code is incorporated)
  3. I need to use 3 optical limit switches. (just order)
  4. The peristaltic pumps need to be turned on using a simple …I don’t know what. At some point, I might look into changing one relay, I guess, back to another stepper using another board and its required pins.
  5. I will need to a real time clock to set the program in motion every so often, throughout the day. (I bought an I2C/SPI/Onewire Shield. I believe that it an on board clock.)

If I have all of this how do I map out all of this? Do I need to get something else or do I need to skip the LCD?

So I can simply hook wires from pins 0, 4, 5, 6, 7, 8, 9 and 10 to anything like 40, 44, 45, 46, 47, 48, 49 and 50?

How do I switch the pin locations in the code?

Hi herring_fish,

Welcome to the RobotShop Forum. The LCD keypad shield has certain pins hardwired to the LCD display, and as such you cannot simply change them if you plan on mounting the shield on top of the Arduino. If you want to use it separately, you can of course add wires between the MEGA pins and the shield, allowing you to use whichever pins you want.

Hope this helps,

Hi,

So long as you don’t stack the shield and wire it separately, you can use whiever pins you want. Note that other shields may need specific pins (for example 0, 1 for Tx Rx, or PWM pins etc.). Unfortunately we cannot go into detail about the code, but the idea should simply be to replace teh pin numbers with whichever you are using.

Sincerely,