serial communication between 2 arduinos

Hi guys i need send data between tow arduinos(mega and Uno) any one have idea. Pleas help me.

I've used a variation of the below serial code between two arduinos.

//zoomkat 3-5-12 simple delimited ',' string tx/rx 
//from serial port input (via serial monitor)
//and print result out serial port
//Connect the sending arduino rx pin to the receiving arduino rx pin. 
//Connect the arduino grounds together. 
//What is sent to the tx arduino is received on the rx arduino.
//Open serial monitor on both arduinos to test

String readString;

void setup() {
  Serial.begin(9600);
  Serial.println("serial delimit test 1.0"); // so I can keep track of what is loaded
}

void loop() {

  //expect a string like wer,qwe rty,123 456,hyre kjhg,
  //or like hello world,who are you?,bye!,

  if (Serial.available())  {
    char c = Serial.read();  //gets one byte from serial buffer
    if (c == ',') {
      if (readString.length() >0) {
        Serial.print(readString); //prints string to serial port out
        Serial.println(','); //prints delimiting ","
        //do stuff with the captured readString 
        readString=""; //clears variable for new input
      }
    }  
    else {     
      readString += c; //makes the string readString
    }
  }
}

You could use any of the examples in serial input basics for receiving the data and send the data in a complementary style.

...R

I have a bunch of stuff, all under a sub-menu at...

http://sheepdogguides.com/arduino/art4SeIntro.htm

Don't be put off by the heading "How To Connect Arduinos to other devices over serial channels".

The "other device" can be another Arduino!

Start small: Connect an Arduino to a big PC, with the Arduino receiving data... preferably, eventually, over something OTHER THAN the "basic" serial link to the Arduino used for programming it, and for the built in "serial monitor". (Though if you are not familiar with the serial monitor, GET familiar... it is a valuable tool, easy to master, and if it isn't, there are things you need to learn about serial comms before your Arduino-to-Arduino project will succeed! (^_^)

Then do an Arduino sending data to the big PC.

Then you will be ready for two Arduinos sending data to each other.