Password lock from Uno to mwga 2560

I am new to this arduino . I have some basic from arduino Uno and would like to transfer my project to arduino mega2560 because it more suitable for my project due to great number of digital port compare with arduino Uno. So my plan is just to change digital port number with from uno to mega 2560then use the same code which is work fine on uno upload in to mega 2560 . I already did that but somehow there is not thing happens when I supply board with 12VDC 1A power supply . but the LED on board indicated the board is on , so is that possible that anyone can please help me and point out what did I do wrong.

What this project objective

Password lock

First it allow user to set password. Then user input password by keypad. If the password is consistent with set password the relay will closed and led indicator light will be on. Otherwise the relay will open and the led light will be off

Connection
Original connection

LCD
RS -0
R/w – GND
E – 1
D4 – 2
D5 – 3
D6 – 4
D7 – 12
Vss – GND
VDD – 5V
A – 3.3v
K-GND

Keypad (4x4) but we use only 4x3

Row 1 - 11
2- 10
3 – 9
4- 8
Colum 1 – 7
2- 6
3- 5
Relay
S – 13

    • = GND

Modified connection

LCD

RS -22
R/w – GND
E – 24
D4 – 26
D5 – 28
D6 – 30
D7 – 46
Vss – GND
VDD – 5V
A – 3.3v
K-GND

Keypad (4x4) but we use only 4x3

Row 1 - 44
2- 42
3 – 40
4- 38

Colum 1 – 36
2- 34
3- 32
Relay
S – 48

    • = GND

Original code

#include <Keypad.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(0, 1, 2, 3, 4, 12);

#define relayPin 13

const byte ROWS = 4; //four rows
const byte COLS = 3; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
byte rowPins[ROWS] = {11, 10, 9, 8}; //connect to the row pinouts of the keypad
byte colPins[COLS] = { 7, 6, 5}; //connect to the column pinouts of the keypad

int pos = 0;
char secretCode[6] = {'1', '2', '3', '4', '5', '6'};
char inputCode[6] = {'0', '0', '0', '0', '0', '0'};

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); 

void setup()
{
  lcd.begin(16, 2);
  pinMode(relayPin, OUTPUT);
  //Serial.begin(9600);
  lcd.setCursor(0,0);
  lcd.print("    Welcome!    ");
  delay(2000);
}
void loop()
{
  readKey();
}

void readKey()
{
  int correct = 0;
  int i;
  char customKey = customKeypad.getKey();
  if (customKey)
  {
    switch(customKey)
    {
      case '*':
        pos = 0;
        lcd.clear();
        lcd.setCursor(0,0);
        lcd.print("Input Your Code:");
      break;
      case '#':    
        for(i = 0; i < 6; i++)
        {
          if(inputCode[i] == secretCode[i])
          {
            correct ++;
          }
        }
        if(correct == 6)
        {
          lcd.clear();
          lcd.setCursor(0, 0);
          lcd.print("Input correctly!");
          lcd.setCursor(0, 1);
          lcd.print(" Please Come In ");
          digitalWrite(relayPin, HIGH);
          delay(2000);
          lcd.clear();
          lcd.setCursor(0,0);
          lcd.print("    Welcome!    ");
        }
        else
        {
          lcd.clear();
          lcd.setCursor(0, 0);
          lcd.print("  Input Error!  ");
          lcd.setCursor(0, 1);
          lcd.print("  Please Again  ");
          digitalWrite(relayPin, LOW);
          delay(2000);
          lcd.clear();
          lcd.setCursor(0,0);
          lcd.print("    Welcome!    ");
        }
      break;
      default:
        inputCode[pos] = customKey;
        lcd.setCursor(pos,1);
        lcd.print(inputCode[pos]);
        pos ++;
    }
  }
}

Modified code on mega (Change Digital pin number)

#include <Keypad.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(22, 24, 26, 28, 30, 46);

#define relayPin 48

const byte ROWS = 4; //four rows
const byte COLS = 3; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
byte rowPins[ROWS] = {44, 42, 40, 38}; //connect to the row pinouts of the keypad
byte colPins[COLS] = { 36, 34, 32}; //connect to the column pinouts of the keypad

int pos = 0;
char secretCode[6] = {'1', '2', '3', '4', '5', '6'};
char inputCode[6] = {'0', '0', '0', '0', '0', '0'};

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); 

void setup()
{
  lcd.begin(16, 2);
  pinMode(relayPin, OUTPUT);
  //Serial.begin(9600);
  lcd.setCursor(0,0);
  lcd.print("    Welcome!    ");
  delay(2000);
}
void loop()
{
  readKey();
}

void readKey()
{
  int correct = 0;
  int i;
  char customKey = customKeypad.getKey();
  if (customKey)
  {
    switch(customKey)
    {
      case '*':
        pos = 0;
        lcd.clear();
        lcd.setCursor(0,0);
        lcd.print("Input Your Code:");
      break;
      case '#':    
        for(i = 0; i < 6; i++)
        {
          if(inputCode[i] == secretCode[i])
          {
            correct ++;
          }
        }
        if(correct == 6)
        {
          lcd.clear();
          lcd.setCursor(0, 0);
          lcd.print("Input correctly!");
          lcd.setCursor(0, 1);
          lcd.print(" Please Come In ");
          digitalWrite(relayPin, HIGH);
          delay(2000);
          lcd.clear();
          lcd.setCursor(0,0);
          lcd.print("    Welcome!    ");
        }
        else
        {
          lcd.clear();
          lcd.setCursor(0, 0);
          lcd.print("  Input Error!  ");
          lcd.setCursor(0, 1);
          lcd.print("  Please Again  ");
          digitalWrite(relayPin, LOW);
          delay(2000);
          lcd.clear();
          lcd.setCursor(0,0);
          lcd.print("    Welcome!    ");
        }
      break;
      default:
        inputCode[pos] = customKey;
        lcd.setCursor(pos,1);
        lcd.print(inputCode[pos]);
        pos ++;
    }
  }
}

Oh and
Potentiometer

both original and modified are the same

middle pin - LCD VO

other pins - GND

thank you

What is your question? Does the Blink example download and work on the Mega?
Does the Uno version work on the Uno?
Is the LCD wiring double checked against the pins in the sketch?
Tried Serial.println() debugging?

MarkT:
What is your question? Does the Blink example download and work on the Mega?
Does the Uno version work on the Uno?
Is the LCD wiring double checked against the pins in the sketch?
Tried Serial.println() debugging?

First sorry for late reply

  1. My question was can we use the same project code and connection from uno, then use in mega2560 by modifying pins connection number in mega

  2. Yes, it works when I have test mega 2560 board with led blink example.

3.Original uno code works well with Uno, but the reason why I move to mega because I will add 11 more with and relays in this project.

  1. Can you please explain how to check “Serial.println() debugging”

Thank you

superknoty:
4. Can you please explain how to check "Serial.println() debugging"

That means putting some Serial.print statements in your code in strategic places so that you can watch the serial monitor and see what the code is doing. Print out variable values in places where they are important and make sure they are what you think they are. Make sure the function you think you are calling is actually getting called. Make sure the if statement you think is true is actually being entered. Things like that.