Problem reading serial data into an array

I’m trying to interface to my Mega 2560 via Serial1 and I’m having a bit of trouble. All I’m trying to do is send 24 digits from my PC my arduino and read them into an array. I’m starting with 3 digits to figure it out but I haven’t had much luck so far. I managed to get Serial1 to work and can receive data and I get a correct output the first time the data is received but after that it all sort of goes wrong.

My code:

int incoming[3];
int i = 0;

void setup() {
Serial.begin(9600);
Serial1.begin(9600); // set the baud rate
Serial.println(“Ready”); // print “Ready” once
}
void loop() {
while(Serial1.available() >= 3){
// fill array
for (int i = 0; i < 3; i++){
incoming = Serial1.read();
_ Serial.print(incoming*);_
_
Serial.print(" ");_
_
///Serial.println();_
_
}_
_
Serial.println();_
_
}_
_
}*_
The data I’m sending: 50 53 53
My Output:
Ready
50 53 53
49 50 53
50 53 50
53 50 53
50 53 50
53 50 53
50 53 50
53 50 53
50 53 50
53 50 53
I have no idea where I’m going wrong and this is the last bit of code I need to figure out to get my project working.
Thanks!

Serial.read() returns an int, but only so that it can return an error, if you try to read when there is nothing to read. Since you only call Serial.read() after checking that there is something to read, the returned value can be stored in a char (array).

Since you are sending chars, doing that might be a good idea. Looking at an ASCII table might be a good idea, too, to see why you are seeing the results that you are.

PaulS: Serial.read() returns an int, but only so that it can return an error, if you try to read when there is nothing to read. Since you only call Serial.read() after checking that there is something to read, the returned value can be stored in a char (array).

Since you are sending chars, doing that might be a good idea. Looking at an ASCII table might be a good idea, too, to see why you are seeing the results that you are.

Actually I realized that. I didn't include my code that converts the ASCII to the corresponding decimal since I knew that was good.

I did find my problem. Apparently my python code was sending the data too fast for the arduino. Adding a few delays seems to have resolved my issue.

I'm trying to interface to my Mega 2560 via Serial1

Are you using a USB/Serial adapter (example FTDI Basic) to connect Serial1 to the PC?

You could also add "start" and "end" characters to your stream, e.g. a couple values that mark the beginning end end of a message.