Interfacing 4x4 keypad with 4 digit 7 segment

Hello i need some help with approach to a code.

I want to use a 4x4 keypad to interface with 4 digit 7 segment display that turns on a led when a correct code is entered. NOW heres the catch, as part of the project i have to use a 74HC573 chip (octal D latch) to display the numbers . I wrote a bunch of functions which can display whatever numbers i want on the 4 digit 7 segment but now i need to be able to enter a specific code with the key pad and check against that and turn on a specified led.

I am not too familiar with code but please help me out here

CODE

/*
  Showing number 0-9 on a Common Anode 7-segment LED display
  Displays the numbers 0-9 on the display, with one second inbetween.
    A
   ---
  F |   | B
  | G |
   ---
  E |   | C
  |   |
   ---
    D
  This example code is in the public domain.
*/

// Pin 2-8 is connected to the 7 segments of the display.

int pinA = 2;
int pinB = 3;
int pinC = 4;
int pinD = 5;
int pinE = 6;
int pinF = 7;
int pinG = 8;
int D1 = 9;
int D2 = 10;
int D3 = 11;
int D4 = 12;
int LE = 43;
#include <LiquidCrystal.h>
const int numRows = 4;       // number of rows in the keypad
const int numCols = 4;       // number of columns
const int debounceTime = 20; // number of milliseconds for switch to be stable


// the setup routine runs once when you press reset:
void setup() {
  // initialize the digital pins as outputs.
  pinMode(pinA, OUTPUT);
  pinMode(pinB, OUTPUT);
  pinMode(pinC, OUTPUT);
  pinMode(pinD, OUTPUT);
  pinMode(pinE, OUTPUT);
  pinMode(pinF, OUTPUT);
  pinMode(pinG, OUTPUT);
  pinMode(D1, OUTPUT);
  pinMode(D2, OUTPUT);
  pinMode(D3, OUTPUT);
  pinMode(D4, OUTPUT);

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
}

void loop() {
  // when a first number is pressed, call the function with the parameter of D1
  // when a second umber is pressed, call the function with the parameter of D2

  Seven(D1);//peramiter
  delay(5);
  Five(D2);
  delay(5);
  Zero(D3);
  delay(5);
  Two(D4);
  delay(5);
}

void Zero(int D) {// Waht int you want on
  digitalWrite(D, LOW);

  //0
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, HIGH);
  digitalWrite(pinF, HIGH);
  digitalWrite(pinG, LOW);
  //delay(2000); // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Zero");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}

/*void Zero(int D) {
  digitalWrite(D, LOW);
  //0
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, HIGH);
  digitalWrite(pinF, HIGH);
  digitalWrite(pinG, LOW);
  delay(2000); // wait for a second
  digitalWrite(LE, HIGH);
  delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Zero");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
  }*/

void One(int D) { //must have D
  digitalWrite(D, LOW);
  //1
  digitalWrite(pinA, LOW);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, LOW);
  digitalWrite(pinE, LOW);
  digitalWrite(pinF, LOW);
  digitalWrite(pinG, LOW);
  //delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("One");
  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}

/*void One() {
  digitalWrite(D1, LOW);
  digitalWrite(D2, LOW);
  digitalWrite(D3, LOW);
  digitalWrite(D4, LOW);
  //1
  digitalWrite(pinA, LOW);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, LOW);
  digitalWrite(pinE, LOW);
  digitalWrite(pinF, LOW);
  digitalWrite(pinG, LOW);
  delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  delay(100);
  digitalWrite(LE,LOW);
  Serial.println ("One");
  }*/

void Two(int D) {
  digitalWrite(D, LOW);

  //2
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, LOW);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, HIGH);
  digitalWrite(pinF, LOW);
  digitalWrite(pinG, HIGH);
  //delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Two");

  digitalWrite(LE, LOW);
  Serial.println ("Two");
  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}

void Three(int D) {
  digitalWrite(D, LOW);

  //3
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, LOW);
  digitalWrite(pinF, LOW);
  digitalWrite(pinG, HIGH);
  //delay(2000);  // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Three");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}

void Four(int D) {
  digitalWrite(D, LOW);

  //4
  digitalWrite(pinA, LOW);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, LOW);
  digitalWrite(pinE, LOW);
  digitalWrite(pinF, HIGH);
  digitalWrite(pinG, HIGH);
  //delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Four");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}

void Five(int D) {
  digitalWrite(D, LOW);

  digitalWrite(D1, LOW);
  digitalWrite(D2, LOW);
  digitalWrite(D3, LOW);
  digitalWrite(D4, LOW);
  //5
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, LOW);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, LOW);
  digitalWrite(pinF, HIGH);
  digitalWrite(pinG, HIGH);
  //delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Five");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}

void Six(int D) {
  digitalWrite(D, LOW);
  //6
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, LOW);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, HIGH);
  digitalWrite(pinF, HIGH);
  digitalWrite(pinG, HIGH);
  //delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Six");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}

void Seven(int D) {
  digitalWrite(D, LOW);
  //7
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, LOW);
  digitalWrite(pinE, LOW);
  digitalWrite(pinF, LOW);
  digitalWrite(pinG, LOW);
  //delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Seven");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}

void Eight(int D) {
  digitalWrite(D, LOW);
  //8
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, HIGH);
  digitalWrite(pinF, HIGH);
  digitalWrite(pinG, HIGH);
  //delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  //delay(2000);
  digitalWrite(LE, LOW);
  Serial.println ("Eight");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}
void Nine(int D) {
  digitalWrite(D, LOW);
  //9
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, LOW);
  digitalWrite(pinF, HIGH);
  digitalWrite(pinG, HIGH);
  //delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Nine ");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}


// We Need to add a the keypad and call the function created using the keypad. ForLoop might be needed

PS : I am not allowed to use a password library i have to check against a a specified input passsword.

(deleted)

Next week . Right now im trying to edit the keypad code right now seee if i can make the two work together

(deleted)

Its not homework per say , its a project , a final project. Ive google like crazy but no one uses an octal D latch to control a 4 segment 7 display. Ive read the DATA sheet but its of no help aside from just telling me the layout of the chip . IM not asking for someone to write the code for me just guidance

UPDATED CODE

still not display the inputs, any guidance plz

/* @file CustomKeypad.pde
  || @version 1.0
  || @author Alexander Brevig
  || @contact alexanderbrevig@gmail.com
  ||
  || @description
  || | Demonstrates changing the keypad size and key values.
  || #
*/
int pinA = 2;
int pinB = 3;
int pinC = 4;
int pinD = 5;
int pinE = 6;
int pinF = 7;
int pinG = 8;
int D1 = 9;
int D2 = 10;
int D3 = 11;
int D4 = 12;
int LE = 43;
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {22, 24, 26, 28}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {23, 25, 27, 29}; //connect to the column pinouts of the keypad

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

void setup() {
  pinMode(pinA, OUTPUT);
  pinMode(pinB, OUTPUT);
  pinMode(pinC, OUTPUT);
  pinMode(pinD, OUTPUT);
  pinMode(pinE, OUTPUT);
  pinMode(pinF, OUTPUT);
  pinMode(pinG, OUTPUT);
  pinMode(D1, OUTPUT);
  pinMode(D2, OUTPUT);
  pinMode(D3, OUTPUT);
  pinMode(D4, OUTPUT);

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  Serial.begin(9600);
}

void loop() {
  char customKey = customKeypad.getKey();

  if (customKey) {
    Serial.println(customKey);
  }

  switch (customKey){
case 1:
  One(D1);
  delay(5);
  break;
}
}
void Zero(int D) {// Waht int you want on
  digitalWrite(D, LOW);

  //0
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, HIGH);
  digitalWrite(pinF, HIGH);
  digitalWrite(pinG, LOW);
  //delay(2000); // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Zero");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}

/*void Zero(int D) {
  digitalWrite(D, LOW);
  //0
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, HIGH);
  digitalWrite(pinF, HIGH);
  digitalWrite(pinG, LOW);
  delay(2000); // wait for a second
  digitalWrite(LE, HIGH);
  delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Zero");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
  }*/

void One(int D) { //must have D
  digitalWrite(D, LOW);
  //1
  digitalWrite(pinA, LOW);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, LOW);
  digitalWrite(pinE, LOW);
  digitalWrite(pinF, LOW);
  digitalWrite(pinG, LOW);
  //delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("One");
  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}

/*void One() {
  digitalWrite(D1, LOW);
  digitalWrite(D2, LOW);
  digitalWrite(D3, LOW);
  digitalWrite(D4, LOW);
  //1
  digitalWrite(pinA, LOW);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, LOW);
  digitalWrite(pinE, LOW);
  digitalWrite(pinF, LOW);
  digitalWrite(pinG, LOW);
  delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  delay(100);
  digitalWrite(LE,LOW);
  Serial.println ("One");
  }*/

void Two(int D) {
  digitalWrite(D, LOW);

  //2
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, LOW);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, HIGH);
  digitalWrite(pinF, LOW);
  digitalWrite(pinG, HIGH);
  //delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Two");

  digitalWrite(LE, LOW);
  Serial.println ("Two");
  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}

void Three(int D) {
  digitalWrite(D, LOW);

  //3
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, LOW);
  digitalWrite(pinF, LOW);
  digitalWrite(pinG, HIGH);
  //delay(2000);  // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Three");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}

void Four(int D) {
  digitalWrite(D, LOW);

  //4
  digitalWrite(pinA, LOW);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, LOW);
  digitalWrite(pinE, LOW);
  digitalWrite(pinF, HIGH);
  digitalWrite(pinG, HIGH);
  //delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Four");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}

void Five(int D) {
  digitalWrite(D, LOW);

  digitalWrite(D1, LOW);
  digitalWrite(D2, LOW);
  digitalWrite(D3, LOW);
  digitalWrite(D4, LOW);
  //5
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, LOW);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, LOW);
  digitalWrite(pinF, HIGH);
  digitalWrite(pinG, HIGH);
  //delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Five");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}

void Six(int D) {
  digitalWrite(D, LOW);
  //6
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, LOW);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, HIGH);
  digitalWrite(pinF, HIGH);
  digitalWrite(pinG, HIGH);
  //delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Six");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}

void Seven(int D) {
  digitalWrite(D, LOW);
  //7
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, LOW);
  digitalWrite(pinE, LOW);
  digitalWrite(pinF, LOW);
  digitalWrite(pinG, LOW);
  //delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Seven");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}

void Eight(int D) {
  digitalWrite(D, LOW);
  //8
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, HIGH);
  digitalWrite(pinF, HIGH);
  digitalWrite(pinG, HIGH);
  //delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  //delay(2000);
  digitalWrite(LE, LOW);
  Serial.println ("Eight");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}
void Nine(int D) {
  digitalWrite(D, LOW);
  //9
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, LOW);
  digitalWrite(pinF, HIGH);
  digitalWrite(pinG, HIGH);
  //delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Nine ");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}

Hi, What model Arduino are you using? What version of the IDE are you using?

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Have you written code JUST to read the keyboard, forget about the display for the moment, and use Serial Monitor in the IDE to output and keypresses?

Thanks.. Tom.. :)

Assumptions: the display is to be multiplexed, the entered digits will be displayed as they are entered.

Multiplexing and waiting for key presses will not play well together using delay(). The reason is while in a delay() the processor does nothing else - like scan the keypad looking for entries. You will need to get ‘blink without delay’ under your belt. In fact an understanding of the first five demos in IDE/file/examples/digital are key.

How much have you got working?

Don’t try to get the display and the keypad working together all at once. Break it down and get individual parts working one at a time then combine/add in other working parts.

Thank you for you replies guys.
So i got it to display a single digit using an inout from the keypad but its displaying on D1 output or first segment of the 4 digit only not. Thats progress. But now i need to be able to display the rest of the inputs and check against them .

I am using multiplexing, yes, but im not sure i follow on the delays concept

UPDATE CODE:

/* @file CustomKeypad.pde
|| @version 1.0
|| @author Alexander Brevig
|| @contact alexanderbrevig@gmail.com
||
|| @description
|| | Demonstrates changing the keypad size and key values.
|| #
*/
int pinA = 2;
int pinB = 3;
int pinC = 4;
int pinD = 5;
int pinE = 6;
int pinF = 7;
int pinG = 8;
int D1 = 9;
int D2 = 10;
int D3 = 11;
int D4 = 12;
int LE = 34;
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte rowPins[ROWS] = {22, 24, 26, 28}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {23, 25, 27, 29}; //connect to the column pinouts of the keypad

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

void setup(){
  Serial.begin(9600);
  pinMode(pinA, OUTPUT);
  pinMode(pinB, OUTPUT);
  pinMode(pinC, OUTPUT);
  pinMode(pinD, OUTPUT);
  pinMode(pinE, OUTPUT);
  pinMode(pinF, OUTPUT);
  pinMode(pinG, OUTPUT);
  pinMode(D1, OUTPUT);
  pinMode(D2, OUTPUT);
  pinMode(D3, OUTPUT);
  pinMode(D4, OUTPUT);

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
}
  
void loop(){
  char customKey = customKeypad.getKey();
  
  if (customKey){
    Serial.println(customKey);
  }
  if (customKey == '1'){
    One(D1);//peramiter
  delay(5);
  }
  if (customKey == '2'){
    Two(D1);//peramiter
  delay(5);
  }
  if (customKey == '3'){
    Three(D1);//peramiter
  delay(5);
  }
  if (customKey == '4'){
    Four(D1);//peramiter
  delay(5);
  }
  if (customKey == '5'){
    Five(D1);//peramiter
  delay(5);
  }
  if (customKey == '6'){
    Six(D1);//peramiter
  delay(5);
  }
  if (customKey == '7'){
    Seven(D1);//peramiter
  delay(5);
  }
  if (customKey == '8'){
    Eight(D1);//peramiter
  delay(5);
  }
  if (customKey == '9'){
    Nine(D1);//peramiter
  delay(5);
  }
  if (customKey == '0'){
    Zero(D1);//peramiter
  delay(5);
  }
  digitalWrite(LE, LOW);
  digitalWrite(LE, HIGH);
  digitalWrite(D1, LOW);
}

void Zero(int D) {// Waht int you want on
 digitalWrite(D, LOW);

  //0
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, HIGH);
  digitalWrite(pinF, HIGH);
  digitalWrite(pinG, LOW);
  //delay(2000); // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Zero");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW); 
}

void One(int D) { //must have D
  digitalWrite(D, LOW);
  //1
  digitalWrite(pinA, LOW);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, LOW);
  digitalWrite(pinE, LOW);
  digitalWrite(pinF, LOW);
  digitalWrite(pinG, LOW);
  //delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("One");
  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}
void Two(int D) {
  digitalWrite(D, LOW);

  //2
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, LOW);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, HIGH);
  digitalWrite(pinF, LOW);
  digitalWrite(pinG, HIGH);
  //delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Two");

  digitalWrite(LE, LOW);
  Serial.println ("Two");
  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}

void Three(int D) {
  digitalWrite(D, LOW);

  //3
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, LOW);
  digitalWrite(pinF, LOW);
  digitalWrite(pinG, HIGH);
  //delay(2000);  // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Three");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}

void Four(int D) {
  digitalWrite(D, LOW);

  //4
  digitalWrite(pinA, LOW);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, LOW);
  digitalWrite(pinE, LOW);
  digitalWrite(pinF, HIGH);
  digitalWrite(pinG, HIGH);
  //delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Four");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}

void Five(int D) {
  digitalWrite(D, LOW);

  digitalWrite(D1, LOW);
  digitalWrite(D2, LOW);
  digitalWrite(D3, LOW);
  digitalWrite(D4, LOW);
  //5
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, LOW);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, LOW);
  digitalWrite(pinF, HIGH);
  digitalWrite(pinG, HIGH);
  //delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Five");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}

void Six(int D) {
  digitalWrite(D, LOW);
  //6
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, LOW);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, HIGH);
  digitalWrite(pinF, HIGH);
  digitalWrite(pinG, HIGH);
  //delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Six");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}

void Seven(int D) {
  digitalWrite(D, LOW);
  //7
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, LOW);
  digitalWrite(pinE, LOW);
  digitalWrite(pinF, LOW);
  digitalWrite(pinG, LOW);
  //delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Seven");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}

void Eight(int D) {
  digitalWrite(D, LOW);
  //8
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, HIGH);
  digitalWrite(pinF, HIGH);
  digitalWrite(pinG, HIGH);
  //delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  //delay(2000);
  digitalWrite(LE, LOW);
  Serial.println ("Eight");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}
void Nine(int D) {
  digitalWrite(D, LOW);
  //9
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, LOW);
  digitalWrite(pinF, HIGH);
  digitalWrite(pinG, HIGH);
  //delay(2000);               // wait for a second
  digitalWrite(LE, HIGH);
  //delay(100);
  digitalWrite(LE, LOW);
  Serial.println ("Nine ");

  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH);
  digitalWrite(D, LOW);
}

@OP

I believe that the following diagram describes the connections among your MEGA, Keypad, Latch (you don’t need the external latch; an internal buffer of the MCU will be used as a software latch), and 4x7-seg Display unit.

Do you want to achieve something like these (from your post, it is not clear to me what you want to achieve)?
(1) You press 1, 2, 3, and 4 from the Keypad and the digits will appear on D1, D2, D3, and D4 positions of the display unit?
(2) When the entered 4-digit number (any combination of 0 to 9) matches with your internal (so called) password, the L (built-in LED of MEGA) will come ON.

kblk-mega2z.png

So what i what to achieve is something along the lines of both 1 and 2. I need to be able display 4 numbers when inputed on the keypad n the display but also be able to check against those numbers with a 4 digit password that i setup and when the inputs are correct it would turn on the led.

OK!

A: What do you want to proceed now?

(1) Do you want to get your posted codes modified/corrected?

or

(2) Do you want to start with a fresh step-by-step approach?

If your posted codes are copied and pasted from somewhere else, then you may forget those codes; rather, you may start with strategy - 2 of the above.

B: Procedures:
(1) Connect the Keypad with your MEGA as per diagram of Post#10 (repeated below). There is no need to connect the Latch and display unit at this moment. We will be playing with Keypad, Serial Monitor, and L.

(2) Upload the following sketch. Enter digits 1, 2, 3, and 4 from the Keypad. Check that the L has come ON.

#include <Keypad.h>
int keyCounter = 0;
char keyCode[5] = "";

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {22, 24, 26, 28}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {23, 25, 27, 29}; //connect to the column pinouts of the keypad

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

void setup()
{
  Serial.begin(9600);
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);  //L is OFF
}

void loop()
{
  char customKey = customKeypad.getKey();
  if (customKey)
  {
    Serial.print(customKey);
    keyCode[keyCounter] = customKey;
    //Serial.println(keyCode[keyCounter], HEX);
    keyCounter++;
    //Serial.println(keyCounter);
    if (keyCounter == 0x04)            //4 digits have already been entered
    {
      int keyValue = atoi(keyCode);  //converting ASCII codes of the entered digits into integer
      if (keyValue == 1234)
      {
        digitalWrite(13, HIGH);
        while (1);
      }
      keyCounter = 0;    //counter reset
      keyCode[5] = "";   //array reset
    }
  }
}

(3) Study the program codes of Step-2; if you have any queries, please don’t hesitate to ask. Now, keep playing with this setup until we come up with 7-segment display unit.

(4) Build the 4x7-segment Display Unit (without using the 74LS573 Latch) as per diagram of Post#10 (Step-1 of this post).

(5) Upload the following sketch. Enter the digits 1, 2, 3, and 4 from the Keypad. Check that the digits have appeared at their respected positions of the display unit/Serial Monitor. Also, check that the L has become ON.

#include <Keypad.h>
int keyCounter = 0;
char keyCode[5] = "";
byte ccCode[4] = {0x00, 0x00, 0x00, 0x00};  //software latch instead of 74LS573 hardware latch
char customKey;

byte lupTable[] = {0x3F, 0x06, 0x5B, 0x4F, 0x66,
                   0x6D, 0x7D, 0x07, 0x7F, 0x6F
                  };  // lookup Table: digit - vs - CCCode: 0 - 9 = 0x3F - 0x6F

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {22, 24, 26, 28}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {23, 25, 27, 29}; //connect to the column pinouts of the keypad

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

void setup()
{
  Serial.begin(9600);
  for (int i = 2; i < 13; i++)
  {
    pinMode(i, OUTPUT);   //DPin-2 to 11 are outputs
  }
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);  //L is OFF
}

void loop()
{
  customKey = customKeypad.getKey();
  if (customKey)
  {
    Serial.print(customKey);
    keyCode[keyCounter] = customKey;
    ccCode[keyCounter] = lupTable[customKey & 0x0F];  //ccCode is stored in array
    //Serial.println(keyCode[keyCounter], HEX);
    keyCounter++;
    //Serial.println(keyCounter);
    if (keyCounter == 0x04)
    {
      int keyValue = atoi(keyCode);
      if (keyValue == 1234)
      {
        digitalWrite(13, HIGH);
        Serial.println();
        while (1);
      }
      keyCounter = 0;
      keyCode[5] = "";
      ccCode[0] = 0x00;
      ccCode[1] = 0x00;
      ccCode[2] = 0x00;
      ccCode[3] = 0x00;
    }
  }
  refreshDisplay();
}


void refreshDisplay()
{
  digitShow(LOW, HIGH, HIGH, HIGH, 0);
  digitShow(HIGH, LOW, HIGH, HIGH, 1);
  digitShow(HIGH, HIGH, LOW, HIGH, 2);
  digitShow(HIGH, HIGH, HIGH, LOW, 3);
}

void digitShow(bool p, bool q, bool r, bool s, int k)
{
  for (int i = 2, j = 0; i < 9, j < 8; i++, j++)
  {
    digitalWrite(i, bitRead(ccCode[k], j));
  }
  digitalWrite(9, p);       
  digitalWrite(10, q);
  digitalWrite(11, r);
  digitalWrite(12, s);
  delay(6);
}

I hv studied about 4x4 Keypad Interfacing With Arduino for my project but now

Q1. Can i have WIFI out-put through Arduino board?

Q2. Which arduino board to be select ?

Q3. Can i connect arduino out put with anroid mobile?

Q4. Code for above requirement?

GolamMostafa: @OP

I believe that the following diagram describes the connections among your MEGA, Keypad, [u]Latch[/u] (you don't need the external latch; an internal buffer of the MCU will be used as a software latch), and 4x7-seg Display unit.

Do you want to achieve something like these (from your post, it is not clear to me what you want to achieve)? (1) You press 1, 2, 3, and 4 from the Keypad and the digits will appear on D1, D2, D3, and D4 positions of the display unit? (2) When the entered 4-digit number (any combination of 0 to 9) matches with your internal (so called) password, the L (built-in LED of MEGA) will come ON.

You can should not drive cc1, cc2, cc3, cc4 from the pins directly, they may have above 40 mA to drive/sink.

Whandall: You can should not drive cc1, cc2, cc3, cc4 from the pins directly, they may have above 40 mA to drive/sink.

I estimated maximun sink current per display device as: ((5-1.5)/680*7)/2 ~= 18 mA which is below 20 mA that a port pin can drive/sink. However, I would not mind to drive the cathode pins of the 7-segment display devices by an ULN2003 driver to offer 'safety margin' to the port pins of the MCU.

GolamMostafa: I estimated maximun sink current per display device as: ((5-1.5)/680*7)/2 ~= 18 mA which is below 20 mA that a port pin can drive/sink.

You use 8 segments and the whole current, not half of it.

(5-1.5)/680*8 ~= 41 mA.

Whandall: You use 8 segments and the whole current, not half of it.

(5-1.5)/680*8 ~= 41 mA.

I have thought that it is multiplexed display unit which receives pulsed current from the source; therefore, the effective current is the average current.

GolamMostafa:
I have thought that it is multiplexed display unit which receives pulsed current from the source; therefore, the effective current is the average current.

Not a good idea and I can not see how that changes 8 segments to 7.

Where would you stop that?

Is 20 A for a millisecond ok?

Whandall: Not a good idea and I can not see how that changes 8 segments to 7.

Where would you stop that?

Is 20 A for a millisecond ok?

As per OP's post, the dot segment is not active.