Keypad

Hello guys!
I will ask you for some help. I hvae keypad, arduino mega and four 7Led-segments displays, which I made it. I wrote program but this only works for numbers from 0-9.
So i will need program like this:
Every pass thru loop, check if a key was pressed.
If it was 0-9, save it in dataArray[digitNumber]. If the next key pressed was not #, save it as digit0 again. Keep doing that until # is received, then send dataArray[digitNumber] to the first display, and add 1 to digitNumber.
After the 4th digit is displayed, reset digitNumber back to the first digit. Arrays start at 0, so for 4 digits you would have digitNumber go 0,1,2,3, when it reached 4 you reset to 0.
Or, once a 0-9 key was pressed, immediately display it, but don't move to the next display until # was pressed so the used can confirm the number he pressed was actually accepted.

#include <Keypad.h>

const byte numRows= 4;
const byte numCols= 4;

//keymap defines the key pressed according to the row and columns just as appears on the keypad
char keymap[numRows][numCols]=
{
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', '+'}
};

byte rowPins[numRows] = {13,12,11,10}; //Rows 0 to 4
byte colPins[numCols]= {9,8,7,6}; //Columns 0 to 4

//initializes an instance of the Keypad class
Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);
#define lr1 14// red
#define lr2 15
#define lr3 16
#define lr4 17
#define lr5 18
#define lr6 19
#define lr7 20
#define lr8 21
#define lr9 22
#define lr10 23
#define lr11 24
#define lr12 25
#define lr13 26
#define lr14 27
#define lz1 28 // green
#define lz2 29
#define lz3 30
#define lz4 31
#define lz5 32
#define lz6 33
#define lz7 34
#define lz8 35
#define lz9 36
#define lz10 37
#define lz11 38
#define lz12 39
#define lz13 40
#define lz14 41
void setup()
{
pinMode(lr1, OUTPUT);
pinMode(lr2, OUTPUT);
pinMode(lr3, OUTPUT);
pinMode(lr4, OUTPUT);
pinMode(lr5, OUTPUT);
pinMode(lr6, OUTPUT);
pinMode(lr7, OUTPUT);
pinMode(lr8, OUTPUT);
pinMode(lr9, OUTPUT);
pinMode(lr10, OUTPUT);
pinMode(lr11, OUTPUT);
pinMode(lr12, OUTPUT);
pinMode(lr13, OUTPUT);
pinMode(lr14, OUTPUT);
pinMode(lz1, OUTPUT);
pinMode(lz2, OUTPUT);
pinMode(lz3, OUTPUT);
pinMode(lz4, OUTPUT);
pinMode(lz5, OUTPUT);
pinMode(lz6, OUTPUT);
pinMode(lz7, OUTPUT);
pinMode(lz8, OUTPUT);
pinMode(lz9, OUTPUT);
pinMode(lz10, OUTPUT);
pinMode(lz11, OUTPUT);
pinMode(lz12, OUTPUT);
pinMode(lz13, OUTPUT);
pinMode(lz14, OUTPUT);
digitalWrite(lr1,LOW);
digitalWrite(lr2,LOW);
digitalWrite(lr3, LOW);
digitalWrite(lr4, LOW);
digitalWrite(lr5, LOW);
digitalWrite(lr6, LOW);
digitalWrite(lr7, LOW);
digitalWrite(lr8, LOW);
digitalWrite(lr9, LOW);
digitalWrite(lr10, LOW);
digitalWrite(lr11, LOW);
digitalWrite(lr12, LOW);
digitalWrite(lr13, LOW);
digitalWrite(lr14, LOW);
digitalWrite(lz1, LOW);
digitalWrite(lz2, LOW);
digitalWrite(lz3, LOW);
digitalWrite(lz4, LOW);
digitalWrite(lz5, LOW);
digitalWrite(lz6, LOW);
digitalWrite(lz7, LOW);
digitalWrite(lz8, LOW);
digitalWrite(lz9, LOW);
digitalWrite(lz10, LOW);
digitalWrite(lz11, LOW);
digitalWrite(lz12, LOW);
digitalWrite(lz13, LOW);
digitalWrite(lz14, LOW);
Serial.begin(9600);
}


void loop()
{
char keypressed = myKeypad.getKey();
if (keypressed != NO_KEY)
{
switch (keypressed)
{
  case '*':
digitalWrite(lr1,LOW);
digitalWrite(lr2,LOW);
digitalWrite(lr3, LOW);
digitalWrite(lr4, LOW);
digitalWrite(lr5, LOW);
digitalWrite(lr6, LOW);
digitalWrite(lr7, LOW);
  break;
  case '0':
digitalWrite(lr1,LOW);
digitalWrite(lr2,LOW);
digitalWrite(lr3, LOW);
digitalWrite(lr4, LOW);
digitalWrite(lr5, LOW);
digitalWrite(lr6, LOW);
  break;
  case '1':
  digitalWrite(lr2, HIGH);
  digitalWrite(lr3, HIGH);
  break;
  case '2':
  digitalWrite(lr1, HIGH);
  digitalWrite(lr2, HIGH);
  digitalWrite(lr7, HIGH);
  digitalWrite(lr5, HIGH);
  digitalWrite(lr4, HIGH);
  break;
    case '3':
  digitalWrite(lr1, HIGH);
  digitalWrite(lr2, HIGH);
  digitalWrite(lr7, HIGH);
  digitalWrite(lr3, HIGH);
  digitalWrite(lr4, HIGH);
  break;
    case '4':
  digitalWrite(lr6, HIGH);
  digitalWrite(lr7, HIGH);
  digitalWrite(lr2, HIGH);
  digitalWrite(lr3, HIGH);
  break;
    case '5':
  digitalWrite(lr1, HIGH);
  digitalWrite(lr6, HIGH);
  digitalWrite(lr7, HIGH);
  digitalWrite(lr3, HIGH);
  digitalWrite(lr4, HIGH);
  break;
    case '6':
  digitalWrite(lr1, HIGH);
  digitalWrite(lr5, HIGH);
  digitalWrite(lr7, HIGH);
  digitalWrite(lr3, HIGH);
  digitalWrite(lr4, HIGH);
  digitalWrite(lr6, HIGH);
  break;
    case '7':
  digitalWrite(lr1, HIGH);
  digitalWrite(lr2, HIGH);
  digitalWrite(lr3, HIGH);
  break;
    case '8':
  digitalWrite(lr1, HIGH);
  digitalWrite(lr2, HIGH);
  digitalWrite(lr3, HIGH);
  digitalWrite(lr4, HIGH);
  digitalWrite(lr5, HIGH);
  digitalWrite(lr6, HIGH);
  digitalWrite(lr7, HIGH);
  break;
    case '9':
  digitalWrite(lr1, HIGH);
  digitalWrite(lr2, HIGH);
  digitalWrite(lr7, HIGH);
  digitalWrite(lr3, HIGH);
  digitalWrite(lr4, HIGH);
  digitalWrite(lr6, HIGH);
  break;
  default:
  Serial.print(keypressed);
}
}
}

I see no effort made in your sketch where # is processed as you are wanting.

To debug, use Serial.print to see what keys are received.
.

Program that I post is not good, for what I wanted. I will like to make program that is describe, but my knowladge is not good enough. So I will be very thankful if somebody post help me to write that program.

Duplicate post deleted.
You need to learn about arrays as well, there is a lot of duplication in your code.
For example:

byte digit0pins[] = {14,15,16,17,18,19,20,}; // g-f-e-d-c-b-a for example
byte digit1pins[] = {21,22,23,24,25,26,27,};
byte digit2pins[] = {28,29,30,31,32,33,34,};
byte digit3pins[] = {35,36,37,38,39,40,41,};

// make a font array to make digits to segments
byte fontArray[] = {
0b00111111, // 0  with x-g-f-e-d-c-b-a, 1 =- segment on
0b00000110, // 1
0b01011011, // 2
//etc
0b01111111, // 8
0b01101111, // 9
};
/* where digits are arranged:
    a
f        b
    g
e        c
    d
*/
// mask to test if segments are to be high or low
byte maskArray[] = {0b00000001, 0b00000010, 0b00000100, 0b00001000, 0b00010000, 0b00100000, 0b01000000,};
byte i; // array index

Then in setup():

// loop thru pins arrays to set them as outputs
for (i=0; i<7; i=i+1){
pinMode (digit0pins[i], OUTPUT);
pinMode (digit1pins[i], OUTPUT);
pinMode (digit2pins[i], OUTPUT);
pinMode (digit3pins[i], OUTPUT);
}

When you want to update a digit:

for (i=0; i<7;i=i+1){
if ((fontArray[digit0] && maskArray[i]) == 0){  // test if segment is equal to 0, turn it off
// for example digit0 = 1, then fontArray[1] = 0b00000110. With i = 0, then 0b00000110 && 0b00000001 = 0,
// so pin for segment A gets turned off
// for example digit0 = 1, then fontArray[1] = 0b00000110. With i = 1, then 0b00000110 && 0b0000010 = 0b00000010,
// so pin for segment B gets turned on

digitalWrite (digit0pins[i]), LOW);                
}
else {                                                                    // otherwise, turn it on
digitalWrite (digit0pins[i]), HIGH);
}
}

That will cut the code size down a lot and make sure pins get written high & low, where you only writing them high.

Now you can work on your loop code.

loop()
{
char keypressed = myKeypad.getKey();
if (keypressed != NO_KEY)
{
if (keypressed >= 48){   www.asciitable.com]www.asciitable.com see if at least a '0' came in
keypressed = keypressed - 48; // yes, so convert from ASCII character to a number,
}
if (keypressed >= 0 && keypressed <=9){ // display valid numbers
switch (digitPlace) // switch between the different digits
{
case 0: // digit0
for (i=0; i<7;i=i+1){
if ((fontArray[keypressed] && maskArray[i]) == 0){  // test if segment is equal to 0, turn it off
// for example digit0 = 1, then fontArray[1] = 0b00000110. With i = 0, then 0b00000110 && 0b00000001 = 0,
// so pin for segment A gets turned off
// for example digit0 = 1, then fontArray[1] = 0b00000110. With i = 1, then 0b00000110 && 0b0000010 = 0b00000010,
// so pin for segment B gets turned on

digitalWrite (digit0pins[i]), LOW);                
}
else {                                                                    // otherwise, turn it on
digitalWrite (digit0pins[i]), HIGH);
}
}
break;
// repeat for case 1,2,3 for the other digits
}
if (keypressed =='#'){  // if # came in, move to next digit
digitPlace = digitPlace +1;
if (digitPlace == 4){
digitPlace = 0;
}
}

Make sense? Make sure you use current limit resistors on the pins connected to LEDs.

How to repeat for case 1,2,3 for the other digits?

Copy & paste, change digit0 to digit1, digit2, digit3.

i got error digit0 was not declered in this scope

if ((fontArray[digit0] && maskArray[i]) == 0){

this is current code:

#include <Keypad.h>

const byte numRows= 4; 
const byte numCols= 4; 

char keymap[numRows][numCols]=
{
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', '+'}
};

byte rowPins[numRows] = {13,12,11,10}; //Rows 0 to 4
byte colPins[numCols]= {9,8,7,6}; //Columns 0 to 4
byte digit0pins[] = {14,15,16,17,18,19,20,}; // g-f-e-d-c-b-a for example
byte digit1pins[] = {21,22,23,24,25,26,27,};
byte digit2pins[] = {28,29,30,31,32,33,34,};
byte digit3pins[] = {35,36,37,38,39,40,41,};

// make a font array to make digits to segments
byte fontArray[] = {
0b00111111, // 0  with x-g-f-e-d-c-b-a, 1 =- segment on
0b00000110, // 1
0b01011011, // 2
0b01001111, // 3
0b01100110, // 4
0b01101101, // 5
0b01111101, // 6
0b00000111, // 7
0b01111111, // 8
0b01101111, // 9
};
/* where digits are arranged:
    a
f        b
    g
e        c
    d
*/
// mask to test if segments are to be high or low
byte maskArray[] = {0b00000001, 0b00000010, 0b00000100, 0b00001000, 0b00010000, 0b00100000, 0b01000000,};
byte i; // array index

//initializes an instance of the Keypad class
Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);

 void setup ()
 {
 // loop thru pins arrays to set them as outputs
for (i=0; i<7; i=i+1){
pinMode (digit0pins[i], OUTPUT);
pinMode (digit1pins[i], OUTPUT);
pinMode (digit2pins[i], OUTPUT);
pinMode (digit3pins[i], OUTPUT);
}
 for (i=0; i<7;i=i+1){
if ((fontArray[digit0] && maskArray[i]) == 0){  // test if segment is equal to 0, turn it off
// for example digit0 = 1, then fontArray[1] = 0b00000110. With i = 0, then 0b00000110 && 0b00000001 = 0,
// so pin for segment A gets turned off
// for example digit0 = 1, then fontArray[1] = 0b00000110. With i = 1, then 0b00000110 && 0b0000010 = 0b00000010,
// so pin for segment B gets turned on

digitalWrite (digit0pins[i]), LOW);                
}
else {                                                                    // otherwise, turn it on
digitalWrite (digit0pins[i]), HIGH);
}
}

void loop ()
{

  char keypressed = myKeypad.getKey();
if (keypressed != NO_KEY)
{
if (keypressed >= 48){   www.asciitable.com]www.asciitable.com see if at least a '0' came in
keypressed = keypressed - 48; // yes, so convert from ASCII character to a number,
}
if (keypressed >= 0 && keypressed <=9){ // display valid numbers
switch (digitPlace) // switch between the different digits
{
case 0: // digit0
for (i=0; i<7;i=i+1){
if ((fontArray[keypressed] && maskArray[i]) == 0){  // test if segment is equal to 0, turn it off
// for example digit0 = 1, then fontArray[1] = 0b00000110. With i = 0, then 0b00000110 && 0b00000001 = 0,
// so pin for segment A gets turned off
// for example digit0 = 1, then fontArray[1] = 0b00000110. With i = 1, then 0b00000110 && 0b0000010 = 0b00000010,
// so pin for segment B gets turned on

digitalWrite (digit0pins[i]), LOW);                
}
else {                                                                    // otherwise, turn it on
digitalWrite (digit0pins[i]), HIGH);
}
}
break;
case 1: // digit1
for (i=0; i<7;i=i+1){
if ((fontArray[keypressed] && maskArray[i]) == 0){  // test if segment is equal to 0, turn it off
// for example digit1 = 1, then fontArray[1] = 0b00000110. With i = 0, then 0b00000110 && 0b00000001 = 0,
// so pin for segment A gets turned off
// for example digit1 = 1, then fontArray[1] = 0b00000110. With i = 1, then 0b00000110 && 0b0000010 = 0b00000010,
// so pin for segment B gets turned on

digitalWrite (digit1pins[i]), LOW);                
}
else {                                                                    // otherwise, turn it on
digitalWrite (digit1pins[i]), HIGH);
}
}
break;
case 2: // digit2
for (i=0; i<7;i=i+1){
if ((fontArray[keypressed] && maskArray[i]) == 0){  // test if segment is equal to 0, turn it off
// for example digit2 = 1, then fontArray[1] = 0b00000110. With i = 0, then 0b00000110 && 0b00000001 = 0,
// so pin for segment A gets turned off
// for example digit0 = 2, then fontArray[1] = 0b00000110. With i = 1, then 0b00000110 && 0b0000010 = 0b00000010,
// so pin for segment B gets turned on

digitalWrite (digit2pins[i]), LOW);                
}
else {                                                                    // otherwise, turn it on
digitalWrite (digit2pins[i]), HIGH);
}
}
break;
case 3: // digit3
for (i=0; i<7;i=i+1){
if ((fontArray[keypressed] && maskArray[i]) == 0){  // test if segment is equal to 0, turn it off
// for example digit3 = 1, then fontArray[1] = 0b00000110. With i = 0, then 0b00000110 && 0b00000001 = 0,
// so pin for segment A gets turned off
// for example digit3 = 1, then fontArray[1] = 0b00000110. With i = 1, then 0b00000110 && 0b0000010 = 0b00000010,
// so pin for segment B gets turned on

digitalWrite (digit3pins[i]), LOW);                
}
else {                                                                    // otherwise, turn it on
digitalWrite (digit3pins[i]), HIGH);
}
}
break;
}
if (keypressed =='#'){  // if # came in, move to next digit
digitPlace = digitPlace +1;
if (digitPlace == 4){
digitPlace = 0;
}
}
}

Add to top of sketch:
byte digit0;
byte digit1;
byte digit2;
byte digit3;
Remove this section from setup():

 for (i=0; i<7;i=i+1){
if ((fontArray[digit0] && maskArray[i]) == 0){  // test if segment is equal to 0, turn it off
// for example digit0 = 1, then fontArray[1] = 0b00000110. With i = 0, then 0b00000110 && 0b00000001 = 0,
// so pin for segment A gets turned off
// for example digit0 = 1, then fontArray[1] = 0b00000110. With i = 1, then 0b00000110 && 0b0000010 = 0b00000010,
// so pin for segment B gets turned on

digitalWrite (digit0pins[i]), LOW);                
}
else {                                                                    // otherwise, turn it on
digitalWrite (digit0pins[i]), HIGH);
}

Now i get error here:
a function-definition is not allowed here before '{' token

void loop ()

[color=red]{[/color]
char keypressed = myKeypad.getKey();
if (keypressed != NO_KEY)
{
#include <Keypad.h>

const byte numRows= 4; 
const byte numCols= 4; 
byte digit0;
byte digit1;
byte digit2;
byte digit3;
char keymap[numRows][numCols]=
{
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', '+'}
};

byte rowPins[numRows] = {13,12,11,10}; //Rows 0 to 4
byte colPins[numCols]= {9,8,7,6}; //Columns 0 to 4
byte digit0pins[] = {14,15,16,17,18,19,20,}; // g-f-e-d-c-b-a for example
byte digit1pins[] = {21,22,23,24,25,26,27,};
byte digit2pins[] = {28,29,30,31,32,33,34,};
byte digit3pins[] = {35,36,37,38,39,40,41,};

// make a font array to make digits to segments
byte fontArray[] = {
0b00111111, // 0  with x-g-f-e-d-c-b-a, 1 =- segment on
0b00000110, // 1
0b01011011, // 2
0b01001111, // 3
0b01100110, // 4
0b01101101, // 5
0b01111101, // 6
0b00000111, // 7
0b01111111, // 8
0b01101111, // 9
};
/* where digits are arranged:
    a
f        b
    g
e        c
    d
*/
// mask to test if segments are to be high or low
byte maskArray[] = {0b00000001, 0b00000010, 0b00000100, 0b00001000, 0b00010000, 0b00100000, 0b01000000,};
byte i; // array index

//initializes an instance of the Keypad class
Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);

 void setup ()
 {
 // loop thru pins arrays to set them as outputs
for (i=0; i<7; i=i+1){
pinMode (digit0pins[i], OUTPUT);
pinMode (digit1pins[i], OUTPUT);
pinMode (digit2pins[i], OUTPUT);
pinMode (digit3pins[i], OUTPUT);
}

void loop ()

{
char keypressed = myKeypad.getKey();
if (keypressed != NO_KEY)
{
if (keypressed >= 48){   www.asciitable.com]www.asciitable.com see if at least a '0' came in
keypressed = keypressed - 48; // yes, so convert from ASCII character to a number,
}
if (keypressed >= 0 && keypressed <=9){ // display valid numbers
switch (digitPlace) // switch between the different digits
{
case 0: // digit0
for (i=0; i<7;i=i+1){
if ((fontArray[keypressed] && maskArray[i]) == 0){  // test if segment is equal to 0, turn it off
// for example digit0 = 1, then fontArray[1] = 0b00000110. With i = 0, then 0b00000110 && 0b00000001 = 0,
// so pin for segment A gets turned off
// for example digit0 = 1, then fontArray[1] = 0b00000110. With i = 1, then 0b00000110 && 0b0000010 = 0b00000010,
// so pin for segment B gets turned on

digitalWrite (digit0pins[i]), LOW);                
}
else {                                                                    // otherwise, turn it on
digitalWrite (digit0pins[i]), HIGH);
}
}
break;
case 1: // digit1
for (i=0; i<7;i=i+1){
if ((fontArray[keypressed] && maskArray[i]) == 0){  // test if segment is equal to 0, turn it off
// for example digit1 = 1, then fontArray[1] = 0b00000110. With i = 0, then 0b00000110 && 0b00000001 = 0,
// so pin for segment A gets turned off
// for example digit1 = 1, then fontArray[1] = 0b00000110. With i = 1, then 0b00000110 && 0b0000010 = 0b00000010,
// so pin for segment B gets turned on

digitalWrite (digit1pins[i]), LOW);                
}
else {                                                                    // otherwise, turn it on
digitalWrite (digit1pins[i]), HIGH);
}
}
break;
case 2: // digit2
for (i=0; i<7;i=i+1){
if ((fontArray[keypressed] && maskArray[i]) == 0){  // test if segment is equal to 0, turn it off
// for example digit2 = 1, then fontArray[1] = 0b00000110. With i = 0, then 0b00000110 && 0b00000001 = 0,
// so pin for segment A gets turned off
// for example digit0 = 2, then fontArray[1] = 0b00000110. With i = 1, then 0b00000110 && 0b0000010 = 0b00000010,
// so pin for segment B gets turned on

digitalWrite (digit2pins[i]), LOW);                
}
else {                                                                    // otherwise, turn it on
digitalWrite (digit2pins[i]), HIGH);
}
}
break;
case 3: // digit3
for (i=0; i<7;i=i+1){
if ((fontArray[keypressed] && maskArray[i]) == 0){  // test if segment is equal to 0, turn it off
// for example digit3 = 1, then fontArray[1] = 0b00000110. With i = 0, then 0b00000110 && 0b00000001 = 0,
// so pin for segment A gets turned off
// for example digit3 = 1, then fontArray[1] = 0b00000110. With i = 1, then 0b00000110 && 0b0000010 = 0b00000010,
// so pin for segment B gets turned on

digitalWrite (digit3pins[i]), LOW);                
}
else {                                                                    // otherwise, turn it on
digitalWrite (digit3pins[i]), HIGH);
}
}
break;
}
if (keypressed =='#'){  // if # came in, move to next digit
digitPlace = digitPlace +1;
if (digitPlace == 4){
digitPlace = 0;
}
}
}

if (keypressed >= 48){ www.asciitable.com]www.asciitable.com see if at least a '0' came in
You need // somewhere.

.

That still not solve an error.

For every { you need a }

Check your pairing :wink:

Now every { have } I think.
But now I get another error :
too few arguments to function 'void digitalWrite(uint8_t, uint8_t)'

digitalWrite (digit3pins[i]), HIGH);

current code:

#include <Key.h>
#include <Keypad.h>
byte digitPlace;
byte digit0;
byte digit1;
byte digit2;
byte digit3;
byte digit0pins[] = {14,15,16,17,18,19,20,}; // g-f-e-d-c-b-a for example
byte digit1pins[] = {21,22,23,24,25,26,27,};
byte digit2pins[] = {28,29,30,31,32,33,34,};
byte digit3pins[] = {35,36,37,38,39,40,41,};
byte fontArray[] = {
0b00111111, // 0  with x-g-f-e-d-c-b-a, 1 =- segment on
0b00000110, // 1
0b01011011, // 2
0b01001111, // 3
0b01100110, // 4
0b01101101, // 5
0b01111101, // 6
0b00000111, // 7
0b01111111, // 8
0b01101111, // 9
};
byte maskArray[] = {0b00000001, 0b00000010, 0b00000100, 0b00001000, 0b00010000, 0b00100000, 0b01000000,};
byte i;
const byte numRows= 4;
const byte numCols= 4;
char keymap [numRows][numCols]=
{
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', '+'}
};
byte rowPins[numRows] = {13,12,11,10}; //Rows 0 to 4
byte colPins[numCols]= {9,8,7,6}; //Columns 0 to 4
Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);

void setup() {
  // put your setup code here, to run once:
for (i=0; i<7; i=i+1){
pinMode (digit0pins[i], OUTPUT);
pinMode (digit1pins[i], OUTPUT);
pinMode (digit2pins[i], OUTPUT);
pinMode (digit3pins[i], OUTPUT);
}
}

void loop() {
  // put your main code here, to run repeatedly:
  char keypressed = myKeypad.getKey();
if (keypressed != NO_KEY)
{
if (keypressed >= 48){  // www.asciitable.com]www.asciitable.com see if at least a '0' came in
keypressed = keypressed - 48; // yes, so convert from ASCII character to a number,
}
if (keypressed >= 0 && keypressed <=9){ // display valid numbers
switch (digitPlace) // switch between the different digits
{
case 0: // digit0
for (i=0; i<7;i=i+1){
if ((fontArray[keypressed] && maskArray[i]) == 0){  // test if segment is equal to 0, turn it off
// for example digit0 = 1, then fontArray[1] = 0b00000110. With i = 0, then 0b00000110 && 0b00000001 = 0,
// so pin for segment A gets turned off
// for example digit0 = 1, then fontArray[1] = 0b00000110. With i = 1, then 0b00000110 && 0b0000010 = 0b00000010,
// so pin for segment B gets turned on

digitalWrite (digit0pins[i]), LOW);                
}
else {                                                                    // otherwise, turn it on
digitalWrite (digit0pins[i]), HIGH);
}
}
break;
case 1: // digit1
for (i=0; i<7;i=i+1){
if ((fontArray[keypressed] && maskArray[i]) == 0){
digitalWrite (digit1pins[i]), LOW);                
}
else {                                                                    // otherwise, turn it on
digitalWrite (digit1pins[i]), HIGH);
}
}
break;
case 2: // digit2
for (i=0; i<7;i=i+1){
if ((fontArray[keypressed] && maskArray[i]) == 0){

digitalWrite (digit2pins[i]), LOW);                
}
else {                                                                    // otherwise, turn it on
digitalWrite (digit2pins[i]), HIGH);
}
}
break;
case 3: // digit3
for (i=0; i<7;i=i+1){
if ((fontArray[keypressed] && maskArray[i]) == 0){  
digitalWrite (digit3pins[i]), LOW);                
}
else {                                                                    // otherwise, turn it on
digitalWrite (digit3pins[i]), HIGH);
}
}
break;
}
if (keypressed =='#'){  // if # came in, move to next digit
digitPlace = digitPlace +1;
if (digitPlace == 4){
digitPlace = 0;
}
}
}
}
}

digitalWrite (digit3pins [ i ] ), HIGH) ;

;-)))))))))))))))))))

Ohhh
it must be digitalWrite(digit3pins [ i ], HIGH);

The only problem now is the error:
'digitPlace' was not declared in this scope

digitPlace = digitPlace +1;

Show your current code.

.

#include <Key.h>
#include <Keypad.h>

byte digit0;
byte digit1;
byte digit2;
byte digit3;
byte digit0pins[] = {14,15,16,17,18,19,20,}; // g-f-e-d-c-b-a for example
byte digit1pins[] = {21,22,23,24,25,26,27,};
byte digit2pins[] = {28,29,30,31,32,33,34,};
byte digit3pins[] = {35,36,37,38,39,40,41,};
byte fontArray[] = {
0b00111111, // 0  with x-g-f-e-d-c-b-a, 1 =- segment on
0b00000110, // 1
0b01011011, // 2
0b01001111, // 3
0b01100110, // 4
0b01101101, // 5
0b01111101, // 6
0b00000111, // 7
0b01111111, // 8
0b01101111, // 9
};
byte maskArray[] = {0b00000001, 0b00000010, 0b00000100, 0b00001000, 0b00010000, 0b00100000, 0b01000000,};
byte i;
const byte numRows= 4;
const byte numCols= 4;
char keymap [numRows][numCols]=
{
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', '+'}
};
byte rowPins[numRows] = {13,12,11,10}; //Rows 0 to 4
byte colPins[numCols]= {9,8,7,6}; //Columns 0 to 4
Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);

void setup() {
  // put your setup code here, to run once:
for (i=0; i<7; i=i+1){
pinMode (digit0pins[i], OUTPUT);
pinMode (digit1pins[i], OUTPUT);
pinMode (digit2pins[i], OUTPUT);
pinMode (digit3pins[i], OUTPUT);
}
}

void loop() {
  // put your main code here, to run repeatedly:
  char keypressed = myKeypad.getKey();
if (keypressed != NO_KEY)
{
if (keypressed >= 48){  // www.asciitable.com]www.asciitable.com see if at least a '0' came in
keypressed = keypressed - 48; // yes, so convert from ASCII character to a number,
}
if (keypressed >= 0 && keypressed <=9){ // display valid numbers
switch (digitPlace) // switch between the different digits
{
case 0: // digit0
for (i=0; i<7;i=i+1){
if ((fontArray[keypressed] && maskArray[i]) == 0){  // test if segment is equal to 0, turn it off
// for example digit0 = 1, then fontArray[1] = 0b00000110. With i = 0, then 0b00000110 && 0b00000001 = 0,
// so pin for segment A gets turned off
// for example digit0 = 1, then fontArray[1] = 0b00000110. With i = 1, then 0b00000110 && 0b0000010 = 0b00000010,
// so pin for segment B gets turned on

digitalWrite (digit0pins[i], LOW);                
}
else {                                                                    // otherwise, turn it on
digitalWrite (digit0pins[i], HIGH);
}
}
break;
case 1: // digit1
for (i=0; i<7;i=i+1){
if ((fontArray[keypressed] && maskArray[i]) == 0){
digitalWrite (digit1pins[i], LOW);                
}
else {                                                                    // otherwise, turn it on
digitalWrite (digit1pins[i], HIGH);
}
}
break;
case 2: // digit2
for (i=0; i<7;i=i+1){
if ((fontArray[keypressed] && maskArray[i]) == 0){

digitalWrite (digit2pins[i], LOW);                
}
else {                                                                    // otherwise, turn it on
digitalWrite (digit2pins[i], HIGH);
}
}
break;
case 3: // digit3
for (i=0; i<7;i=i+1){
if ((fontArray[keypressed] && maskArray[i]) == 0){  
digitalWrite (digit3pins[i], LOW);                
}
else {                                                                    // otherwise, turn it on
digitalWrite (digit3pins[i], HIGH);
}
}
break;
}
if (keypressed =='#'){  // if # came in, move to next digit
digitPlace = digitPlace +1;
if (digitPlace == 4){
digitPlace = 0;
}
}
}
}
}

Why did you delete this line at the top of the sketch?

byte digitPlace; <---------<<<<

You are going to have to pay more attention to what you are doing.

You need a lot more practice on how to trouble shoot.

Go back to some basic sketches and learn basic programming.

.