user27418: I have the following components:

Arduino Mega
7-segment display
12-digit key-pad

For my project, I would like to display on the 7-segment display the number that the user presses on the keypad.

user27157: Try this: please note that you have to fill in the last function in order to get an int value from your keypad. The 7-segments part of the code should be fine.    
const int segment[7] = {2,3,4,5,6,7,8}; //pins for each segment

const int nums[10][7] = //declaring array
{
  {1,1,1,1,1,1,0}, //0
  {0,1,1,0,0,0,0}, //1
  {1,1,0,1,0,0,1}, //2
  {1,1,1,1,0,0,1}, //3
  {0,1,1,0,0,1,1}, //4
  {1,0,1,1,0,1,1}, //5
  {1,0,1,1,1,1,1}, //6
  {1,1,1,0,0,0,0}, //7
  {1,1,1,1,1,1,1}, //8
  {1,1,1,0,0,1,1}  //9
};

void setup() {
  for(int i=2; i<=8; i++) //shorcut for declaring a buch of pin modes
  {
    pinMode(i, OUTPUT);
  }
}

//=======================================================================

void loop() {
  number(keypadInput);
}

//=======================================================================

void number(int num) //num is the number to display
{
  for(int i=0; i<7; i++)
  {
    digitalWrite(segment[i], nums[num][i]);
  }
}

int (keypadInput)
{
  //code for getting the input of your keypad
}


27418: <p>I have the following components:</p>

<ul>
<li>Arduino Mega</li>
<li>7-segment display</li>
<li>12-digit key-pad</li>
</ul>

<p>For my project, I would like to display on the 7-segment display the number that the user presses on the keypad.</p>
 27157: <p>Try this: please note that you have to fill in the last function in order to get an int value from your keypad. The 7-segments part of the code should be fine.    </p>

<pre><code>const int segment[7] = {2,3,4,5,6,7,8}; //pins for each segment

const int nums[10][7] = //declaring array
{
  {1,1,1,1,1,1,0}, //0
  {0,1,1,0,0,0,0}, //1
  {1,1,0,1,0,0,1}, //2
  {1,1,1,1,0,0,1}, //3
  {0,1,1,0,0,1,1}, //4
  {1,0,1,1,0,1,1}, //5
  {1,0,1,1,1,1,1}, //6
  {1,1,1,0,0,0,0}, //7
  {1,1,1,1,1,1,1}, //8
  {1,1,1,0,0,1,1}  //9
};

void setup() {
  for(int i=2; i&lt;=8; i++) //shorcut for declaring a buch of pin modes
  {
    pinMode(i, OUTPUT);
  }
}

//=======================================================================

void loop() {
  number(keypadInput);
}

//=======================================================================

void number(int num) //num is the number to display
{
  for(int i=0; i&lt;7; i++)
  {
    digitalWrite(segment[i], nums[num][i]);
  }
}

int (keypadInput)
{
  //code for getting the input of your keypad
}
</code></pre>
