Arduino to arduino communication

i am trying to connect two arduinos using serial wired communication.
Arduino1 will be interfaced with a 4 x 3 keypad and Arduino2 will be interfaced with a seven segment display.
the key pressed on keypad must be displayed on seven segment display.
but i am unable to work it out please see what's wrong.
code for arduino1

#define R1 3  //pin 1
#define R2 4  //pin 2
#define R3 5  //pin 3
#define R4 6  //pin 4
#define C1 7  //pin 5
#define C2 8  //pin 6
#define C3 9  //pin 7
int key=12;
void setup()
{
  // put your setup code here, to run once:
  Serial.begin(9600);
keypadinit();
}

void loop() {
  // put your main code here, to run repeatedly:
keycheck();
}

void keycheck(void)
{
digitalWrite(C1,LOW);digitalWrite(C2,HIGH);digitalWrite(C3,HIGH);//READS FIRST COLUMN
if(digitalRead(R1)==0) {key=1;}
if(digitalRead(R2)==0) {key=4;}
if(digitalRead(R3)==0) {key=7;}
if(digitalRead(R4)==0) {key=10;}
digitalWrite(C1,HIGH);digitalWrite(C2,LOW);digitalWrite(C3,HIGH);//READS FIRST COLUMN
if(digitalRead(R1)==0) {key=2;}
if(digitalRead(R2)==0) {key=5;}
if(digitalRead(R3)==0) {key=8;}
if(digitalRead(R4)==0) {key=0;}
digitalWrite(C1,HIGH);digitalWrite(C2,HIGH);digitalWrite(C3,LOW);//READS FIRST COLUMN
if(digitalRead(R1)==0) {key=3;}
if(digitalRead(R2)==0) {key=6;}
if(digitalRead(R3)==0) {key=9;}
if(digitalRead(R4)==0) {key=11;}

if(key<12) {Serial.write(key); keydelay();  }
}


//FUNCTIONS
void keypadinit(void)
{
pinMode(C1,OUTPUT);pinMode(C2,OUTPUT);pinMode(C3,OUTPUT);
pinMode(R1,INPUT_PULLUP);pinMode(R2,INPUT_PULLUP);pinMode(R3,INPUT_PULLUP);pinMode(R4,INPUT_PULLUP); //pull up
}
void keydelay(void)
{
delay(300);
}

Code for Arduino2

// ProjectsDunia
// http://projectsdunia.blogspot.in
// http://facebook.com/projectsdunia
int a=2;
int b=3;
int c=4;
int d=5;
int e=6;
int f=7;
int g=8;
int h=9;

void setup() 
{               
  pinMode(a, OUTPUT);  
  pinMode(b, OUTPUT);
  pinMode(c, OUTPUT);
  pinMode(d, OUTPUT);
  pinMode(e, OUTPUT);
  pinMode(f, OUTPUT);
  pinMode(g, OUTPUT);
  pinMode(h, OUTPUT);
  digitalWrite(h, 0);  // start with the "dot" off
}

void loop() 
{
 if(Serial.available()>0)
  {
    char letter= Serial.read();
    if(letter=='9')
    {
       digitalWrite(a, 1);
 digitalWrite(b, 1);
 digitalWrite(c, 1);
 digitalWrite(d, 0);
 digitalWrite(e, 0);
 digitalWrite(f, 1);
 digitalWrite(g, 1);
 
      }
      else if(letter=='8')
      {
         // write '8'
 digitalWrite(a, 1);
 digitalWrite(b, 1);
 digitalWrite(c, 1);
 digitalWrite(d, 1);
 digitalWrite(e, 1);
 digitalWrite(f, 1);
 digitalWrite(g, 1);

        }
        else if(letter == '7')
        {
          // write '7'
 digitalWrite(a, 1);
 digitalWrite(b, 1);
 digitalWrite(c, 1);
 digitalWrite(d, 0);
 digitalWrite(e, 0);
 digitalWrite(f, 0);
 digitalWrite(g, 0);
 
          }
          else if(letter == '6')
        {
 // write '6'
 digitalWrite(a, 1);
 digitalWrite(b, 0);
 digitalWrite(c, 1);
 digitalWrite(d, 1);
 digitalWrite(e, 1);
 digitalWrite(f, 1);
 digitalWrite(g, 1);
 
          } else if(letter == '5')
        { // write '5'
 digitalWrite(a, 1);
 digitalWrite(b, 0);
 digitalWrite(c, 1);
 digitalWrite(d, 1);
 digitalWrite(e, 0);
 digitalWrite(f, 1);
 digitalWrite(g, 1);
 
          }else if(letter == '4')
        {  // write '4'
 digitalWrite(a, 0);
 digitalWrite(b, 1);
 digitalWrite(c, 1);
 digitalWrite(d, 0);
 digitalWrite(e, 0);
 digitalWrite(f, 1);
 digitalWrite(g, 1);
 
          }else if(letter == '3')
        { // write '3'
 digitalWrite(a, 1);
 digitalWrite(b, 1);
 digitalWrite(c, 1);
 digitalWrite(d, 1);
 digitalWrite(e, 0);
 digitalWrite(f, 0);
 digitalWrite(g, 1);
 
          }else if(letter == '2')
        { // write '2'
 digitalWrite(a, 1);
 digitalWrite(b, 1);
 digitalWrite(c, 0);
 digitalWrite(d, 1);
 digitalWrite(e, 1);
 digitalWrite(f, 0);
 digitalWrite(g, 1);

          }else if(letter == '1')
        { // write '1'
 digitalWrite(a, 0);
 digitalWrite(b, 1);
 digitalWrite(c, 1);
 digitalWrite(d, 0);
 digitalWrite(e, 0);
 digitalWrite(f, 0);
 digitalWrite(g, 0);
 
          }else if(letter == '0')
        { // write '0'
 digitalWrite(a, 1);
 digitalWrite(b, 1);
 digitalWrite(c, 1);
 digitalWrite(d, 1);
 digitalWrite(e, 1);
 digitalWrite(f, 1);
 digitalWrite(g, 0);
 
          }
  }

}

attached is the schematic

I see only one wire connecting the two Arduinos. The grounds need to be connected, too.

The code you posted (properly, thank you) does something. You didn't say what it does.

You want the code to do something. You didn't say what.

PaulS:
I see only one wire connecting the two Arduinos. The grounds need to be connected, too.

The code you posted (properly, thank you) does something. You didn't say what it does.

You want the code to do something. You didn't say what.

what you didn't get about the code?
first code reads a key from keypad writes it value on serial tx port.
while second code reads from serial rx port and displays corresponding key value on display.

OK. So, everything works. Great.

Did you have a question?

Did you add a ground wire?

PaulS:
OK. So, everything works. Great.

Did you have a question?

no it is supposed work it like this but it doesn't and i don't know why.can you please take a look.

mehroz:
no it is supposed work it like this but it doesn't and i don't know why.can you please take a look.

Can you read? You haven't answered reply#1 or #4.

aarg:
Can you read? You haven't answered reply#1 or #4.

i cannot find aground wire on arduino in proteus can you please tell me where it is.?

aarg:
Did you add a ground wire?

where do i find the ground wire on arduino in proteus.?

The simulator probably has an implied ground reference, in which case you may not need to connect it. On the other hand, the possibility of connecting two Arduinos may have been overlooked in the model. It would have been polite to share this with us from the start. Most people are using read hardware.

aarg:
The simulator probably has an implied ground reference, in which case you may not need to connect it. On the other hand, the possibility of connecting two Arduinos may have been overlooked in the model. It would have been polite to share this with us from the start. Most people are using read hardware.

ok let me share the proteus design file.

Write a simpler sketch to see only if you can transmit one character. Leave out the seven segment and keypad part.