So recently i got my hands on an arduino mega, because i need to send data from a Raspberry pi 0 w to an arduino via Serial and want to debug it. (B.c. the mega has multiple serial ports).
So the raspberry is sending an array of bytes (size: 29) every second. I know that everything on the sending side (Raspberry) works perfectly fine.
But when i run this code here on the arduino:
int dataArray[29];
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
}
void loop() {
int x = 0;
while(Serial1.available() > 0) {
dataArray[x] = Serial1.read();
++x;
}
for(int i; i <= 28; ++i) {
Serial.println(dataArray[i]);
}
}