Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 51 - Ai Robogenius
P. 51

    Loops Blocks

                     Loops blocks allow you to repeat actions multiple times. Some of the important
                     loops blocks are:

                                          Block                                          Description

                                                                        Repeats  a set  of actions  a specific
                                      repeat  4   times
                                                                        number of times.
                                      do

                                                                        Executes actions continuously as long
                                     while    false
                                                                        as a condition is true.
                                     do

                                                                        Runs a set of actions a specific number
                               for    index      from 0 to  4
                                                                        of times, iterating over a range.
                               do

                                                                        Iterates over each element in a list or
                              for element  value   of   list
                                                                        array.
                              do

                                                                        Executes  a set  of actions  at  regular
                                      every   500   ms
                                                                        time intervals.

                                                                        Exits the current loop immediately.
                                            break

                                                                        Skips  the  rest  of the current iteration
                                          continue
                                                                        and moves to the next one.

                     Variable Blocks

                     Variables  are like  labelled boxes  that  store information  your  program  can use,
                     change and display. You can use them to store numbers, text or any other information
                     that needs to be updated or referenced throughout your project. To create your own

                     variable, click on the Make a Variable button.

                                                                                         Coding with Micro:Bit
                                                                                                                        49

| 46 47 48 49 50 51 52 53 54 55 56 |