user47354: i want to send an array of int to another arduino by serial.
To garantie a better robust during the transmission, i added < and > with endMarker and startMarker.
The receiver wait until the Hardware Serial is open, and read the data from the Software Serial from the sender.
Code for the sender:
int test[] = {1, 2, 3, 4, 5, 6, 7};

void setup() {
  Serial.begin(9600); // Hardware Serial
}

void loop() {
  for (byte i = 0; i < 7; i++) {
    Serial.write("<");
    Serial.write(test[i]);
    Serial.write(">");
    delay(500);
  }
}

Code for the reader, i edited the code from here: http://forum.arduino.cc/index.php?topic=396450
// Example 3 - Receive with start- and end-markers

include <SoftwareSerial.h>

const byte numChars = 32;
char receivedChars[numChars];

boolean newData = false;

SoftwareSerial mySerial(10, 11); // RX, TX Software Serial

void setup() {
    Serial.begin(9600);
    mySerial.begin(9600);
    Serial.println("<Arduino is ready>");
}

void loop() {
    recvWithStartEndMarkers();
    showNewData();
}

void recvWithStartEndMarkers() {
    static boolean recvInProgress = false;
    static byte ndx = 0;
    char startMarker = '<';
    char endMarker = '>';
    char rc;

    while (Serial.available() > 0 && newData == false) {
        rc = mySerial.read();

        if (recvInProgress == true) {
            if (rc != endMarker) {
                receivedChars[ndx] = rc;
                ndx++;
                if (ndx >= numChars) {
                    ndx = numChars - 1;
                }
            }
            else {
                receivedChars[ndx] = '\0'; // terminate the string
                recvInProgress = false;
                ndx = 0;
                newData = true;
            }
        }

        else if (rc == startMarker) {
            recvInProgress = true;
        }
    }
}

void showNewData() {
    if (newData == true) {
        Serial.print("This just in ... ");
        Serial.println(receivedChars);
        newData = false;
    }
}

I don't know if the problem is the serial.write, that send bytes, or i need to use serial.print to send string.

user4143: You are attempting to use an 8-bit binary protocol to transmit 16 bit values, and then wrapping it in ASCII characters.  There is:

No way to differentiate the ASCII characters from the 8 bit binary data, and
No way to fit 16 bits into an 8 bit protocol.

The simplest way is to use Serial.print to make the whole protocol ASCII:
Serial.print("<");
for (byte i = 0; i < 7; i++) {
  Serial.print(test[i]);
  if (i < 6) {
    Serial.print(",");
  }
}
Serial.println(">");

Which would send out:
<1,2,3,4,5,6,7>


47354: <p>i want to send an array of int to another arduino by serial.</p>

<p>To garantie a better robust during the transmission, i added &lt; and > with endMarker and startMarker.</p>

<p>The receiver wait until the Hardware Serial is open, and read the data from the Software Serial from the sender.</p>

<p>Code for the sender:</p>

<pre><code>int test[] = {1, 2, 3, 4, 5, 6, 7};

void setup() {
  Serial.begin(9600); // Hardware Serial
}

void loop() {
  for (byte i = 0; i &lt; 7; i++) {
    Serial.write("&lt;");
    Serial.write(test[i]);
    Serial.write("&gt;");
    delay(500);
  }
}
</code></pre>

<p>Code for the reader, i edited the code from here: <a href="http://forum.arduino.cc/index.php?topic=396450" rel="nofollow noreferrer">http://forum.arduino.cc/index.php?topic=396450</a></p>

<pre><code>// Example 3 - Receive with start- and end-markers

include &lt;SoftwareSerial.h&gt;

const byte numChars = 32;
char receivedChars[numChars];

boolean newData = false;

SoftwareSerial mySerial(10, 11); // RX, TX Software Serial

void setup() {
    Serial.begin(9600);
    mySerial.begin(9600);
    Serial.println("&lt;Arduino is ready&gt;");
}

void loop() {
    recvWithStartEndMarkers();
    showNewData();
}

void recvWithStartEndMarkers() {
    static boolean recvInProgress = false;
    static byte ndx = 0;
    char startMarker = '&lt;';
    char endMarker = '&gt;';
    char rc;

    while (Serial.available() &gt; 0 &amp;&amp; newData == false) {
        rc = mySerial.read();

        if (recvInProgress == true) {
            if (rc != endMarker) {
                receivedChars[ndx] = rc;
                ndx++;
                if (ndx &gt;= numChars) {
                    ndx = numChars - 1;
                }
            }
            else {
                receivedChars[ndx] = '\0'; // terminate the string
                recvInProgress = false;
                ndx = 0;
                newData = true;
            }
        }

        else if (rc == startMarker) {
            recvInProgress = true;
        }
    }
}

void showNewData() {
    if (newData == true) {
        Serial.print("This just in ... ");
        Serial.println(receivedChars);
        newData = false;
    }
}
</code></pre>

<p>I don't know if the problem is the serial.write, that send bytes, or i need to use serial.print to send string.</p>
 4143: <p>You are attempting to use an 8-bit binary protocol to transmit 16 bit values, and then wrapping it in ASCII characters.  There is:</p>

<ul>
<li>No way to differentiate the ASCII characters from the 8 bit binary data, and</li>
<li>No way to fit 16 bits into an 8 bit protocol.</li>
</ul>

<p>The simplest way is to use <code>Serial.print</code> to make the whole protocol ASCII:</p>

<pre><code>Serial.print("&lt;");
for (byte i = 0; i &lt; 7; i++) {
  Serial.print(test[i]);
  if (i &lt; 6) {
    Serial.print(",");
  }
}
Serial.println("&gt;");
</code></pre>

<p>Which would send out:</p>

<pre><code>&lt;1,2,3,4,5,6,7&gt;
</code></pre>
