Arduino – While Loop
The While loop can execute a set of commands till the condition is true. While Loops are also called conditional loops. Once the condition is met then the loop is finished.
General Flow of While Loop

Implementing While Loop in PictoBlox
The Repeat Until () block is a Control Block and a C block. Blocks held inside this block will loop until the specified boolean statement is true, in which case the code beneath the block (if any) will execute. This loop is in similar nature to a while loop.

Activity 1
Let’s create a code to print 1-9 numbers on the LED of Quarky.
Flow Chart

Code
- Drag When green flag clicked block from Events palette. Next, make a variable and name it Count. Use a set my variable to () block from the Variables palette and set the Count variable to 1.

- Add a repeat until () block from the Control palette. Use < (less than) block with from Operators palette. To check if the variable Count is less than 10 or not.

- If the variable Count is less than 10 then we want the Quarky display LED to be in green color.

- Add a wait () seconds block from the Control palette with value 1. So the code will wait for one second and then change the variable Count value by 1 using the change my variable by () block from the Variables palette.

Test

Activity 2
Let’s create a code to print 9 to 1 numbers on the LED of Quarky.

Test

Assignment
Before you move on to the next lesson, a small assignment awaits you!
You must upload the PictoBlox program you created in this activity to the website. Submitting the assignment is a must in order to receive the certificate after completing the course.
Follow the steps below to upload your assignment:
- Click on Browse.
- Search and Select your saved Project file(.sb3) and Click Open.
- Click on Upload to submit the assignment.

Good luck!