The most minimalistic sketch to get some words onto the serial monitor is
void setup() {
// activate serial interface with a baudrate of 115200
Serial.begin(115200);
Serial.println( F("Hello World") );
}
void loop() {
}
As setup runs only once per power-on / reset
a single line with the coded words "Hello World" apears in the serial monitor
With each pressing of the reset-button the program starts new sending this single line with Hello World
Next step is to use
Serial.print()
inside function loop.
preliminary remark
The function of delay() is easy to understand.
However, there is a serious disadvantage of delay().
You get used to a programming style that greatly hinders multifunctionality.
I will explain the bad properties of delay().
These bad qualities are the almost total blocking of code execution.
So here is the bad example
int myCounter = 0;
void setup() {
// activate serial interface with a baudrate of 115200
Serial.begin(115200);
Serial.println( F("setup finished") );
}
void loop() {
myCounter++; // increase value if variable myCounter by 1
Serial.print( F("myCounter has value ") );
Serial.println(myCounter);
delay(1000); // block code-execution for 1000 milliseconds = 1 second
}
This is the output seen in the serial monitor
There is only one line
![]()
Showing that setup is really executed only once
and there are multiple lines

showing how function loop is "looping"
From the timestamps on the left you can see that each new line is printed approximated one second after the line before
The variable counter is increased once per iteration and as the code-execution is blocked by the delay(1000); the variable myCounter is increased only once per second.
In the next post I introduce you to the non-blocking timing that enables much more functionality like
- flashing any kind of LED pattern and still react on a button-press at any time
- driving a stepper-motor and react on a limit-switch at any time
- executing some code at high speed while other code is only executed once every 3 seconds or once every 7 days



