Goal: Blinking "Hello World" continuously.
A while loop is a statement that allows code to be executed repeatedly based on a given boolean condition. The while construct consists of a block of statements and a condition. The condition is evaluated, and if the condition is true, the statements are executed. This repeats until the condition becomes false.
Syntax:
while (condition) { statements; }
On the actions window, there is a button on the upper left hand corner with a "?" and a cycle on it. This is a while loop block.
Click on that to get two blocks on the screen. The top one receives a condition and everything between it and the bottom block executes as long as it is true.
Click on the red arrow on the while block. Click on the Tick mark. It means the condition is true. Here we have created a never ending loop. This is necessary as we want the "Hello World" blinking continuously on the display.
The complete program is shown below.
Activity: Blink "Hello World" for 10 times.