How to transfer data arduino to arduino using serial com

i want to create a program that will transfer data arduino to arduino using serial com, anybody can help me please?? :slight_smile:
thanks

You will, of course, need two programs. One to send the data and another to receive it.

What is the nature of the data that you want to transfer ?

You can use the examples in Serial Input Basics to receive the data. I would recommend the 3rd example for max reliability.

Just get the sending code to match the requirement of the receiving code.

...R

If you have ever done something with Serial Monitor, think of the second Arduino as Serial monitor.

So Serial Monitor (second Arduino) sends something, first Arduino receives and replies and Serial Monitor 'displays' it; 'display' in this case means 'whatever needs to be done'.

Using Serial Monitor itself initially allows you to write the code for the first Arduino and debug it. Next you can swap the positions around and develop the code for the first Arduino. At the end you connect the two and you're good to go :wink:

Simple serial test code you might put on both arduinos to see if you can get the desired communication.

//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 tx 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
//A diode between the slave tx and master rx is suggested 
//for isolation, with diode band attached to slave tx side. 
//

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
    }
  }
}