Basically, when using a For loop, Serial.print is only printing at the end. Tried this on a Nano and a Mega. Using IDE 1.8.19.
From the code below, I get this in the serial monitor:
Hi
h: 4
k: 6
void setup()
{
Serial.begin(9600);
Serial.print("\r\nHi");
Read();
}
void Read()
{
byte h;
byte k = 6;
for (h = 0; h < 4; h++);
{
if (h == 2) k++;
Serial.print("\r\n h: ");
Serial.print(h);
Serial.flush();
}
Serial.print("\r\n k: ");
Serial.print(k);
}
void loop()
{
}