Interfacing 4x4 keypad with 4 digit 7 segment

But in your f... picture. Come on, cant you admit being wrong?

Whandall:
But in your f... picture.

I have been used to be with this Western vocabulary: f...

There is no DPin assigned to the dot (p) segment; there is also no code in the sketch that drives the dot segment. Under this spec, I am fine to calculate consumed current only for 7-segment of the display unit. As a result, the maximum sink current (18 mA ~= ((5-1.5)/680*7)/2) per display device remains below safe limit of 20 mA (IOH/IOL of ATmega328P Port-pin); I am waived of using a driver for the cc-pins of the display devices.

ANKIT79:
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?

ESP8266 based board like NodeMCU has a built-in WiFi. The board is supported by Arduino IDE and as such you can use it like an Arduino Board. It also supports Bluetooth Module to have communication with android Mobile. However, the board does not have enough IO pins to support 4x4 Keypad.

GolamMostafa:
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. 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 digaram of Post#10.

**(5)** Upload the following sketch. Enter the digits 1, 2, 3, and 4 from the Keypad. Check that the digits have appeared at the right positions of the display unit. 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);
}

Okay thank you for your reply however im unable to display all 4 inputs at the same time on the 4 digit 7 segment so i have tweaked the project a little bit to make it simpler. I have instead opted to use 2 separate 7 segment displays each wired to a LS573 which uses it as a buffer to hold the user input. I want to be able to display the user input in the keypad on the 2 7 segments in sets of two's.
For example if user inputs passcode 1 2 3 4 it would display 1 2 on first than followed by 3 4. Then i would do a serial print on the monitor to display the all four numbers. I have only two buffers or else id do all four in one shot.

So far i have this code working i can take a user inputed but im having trouble with the displays on the 7 segments. It seems to display arbitrarily on which ever 7 segment it wants i cant control where users input goes.

Code is too large to post because of character limits so i attached it below

CODE.txt (11.2 KB)

Please, execute (tested) the following slightly modified codes. Now, you will be seeing the visible charcaters 1, 2, 3, and 4 (or any other combinations) on 7-segment the display unit.

#include <Keypad.h>
int keyCounter = 0;
char keyCode[5] = "";
byte ccCode[4] = {0x00, 0x00, 0x00, 0x00};
char customKey;
//void refreshDisplay(void);

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);//(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)
        {
          refreshDisplay();
        }
      }
    }
    // 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);
}