Serial does not output the contents of the array

My code doesn't work the way I want it to, it doesn't output the contents of my array and it doesn't output the read. However, if I remove the condition (if(read[j] != -1)) everything works.

bool isRead = false;
int read[30];
String query[30];

void setup() {
Serial.begin(9600);
  pinMode(13, 1);

  for (int j = 0; j < sizeof(query); j++) {
    read[j] = -1;
    query[j] = "";
  }
}

void loop() {
 for(int j = 0; Serial.available(); j++) { 
    read[j] = Serial.read();
    Serial.write(read[j]);
    delay(50);
    isRead = true;
  }

  if (isRead)
  for (int j = 0; j < 30; j++)
  {
    if (read[j] != -1)
    {
      Serial.write('1');
    }
  }
}

Try to print

you will be surprised, it is not a size of array.

wow, i forgot, thanks

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.