Page 92 - Robo_Genius_V1.0_flipbook_C5
P. 92

Output


                  The  program  uses a  variable called
                  “direction” to store a random number.

                     • Variables  store  numbers  or  values  that
                     can change in a computer program.

                     • Shake the micro:bit to set “direction” to

                     a random number between one and three.
                     • The  program  then  uses  selection  and
                     comparison logic blocks to test the value

                     of the variable.

                     • If “direction”  is equal  to  1, then  an  arrow  pointing  north  shows  on  the
                     micro:bit’s LED display. If “direction” is equal to 2, then the arrow points
                     east. Otherwise, the arrow points west.

                     • To make the battery last longer, the program pauses for half a second after

                     the arrow appears then clears the screen.

                  Concepts

                  1. Direction Detection using Accelerometer: You will learn how the micro:bit’s

                     accelerometer detects tilts and movements in different directions. They will
                     understand how devices sense motion and use this information to trigger an

                     output.
                  2.  Conditional Logic in Programming: You will explore how to use “if-else”

                     logic  to  create  conditions  for  displaying specific arrow  directions.  For
                     example, if the micro:bit is tilted to the right, a right-facing arrow will blink,

                     reinforcing their understanding of logic-based decisions in programming.
                  3.  Visual Output on LED Grid: You will learn how to control the LED display by

                     programming the micro:bit to show different arrow symbols that represent
                     the direction detected by the accelerometer. This concept connects to visual

                     representation in programming.

                  Observations


                  In the Direction Blinking Arrow using Micro:bit activity, you will observe how
                  the micro:bit responds to tilting in various directions. When the micro:bit is

                  tilted to the right, a blinking right arrow appears, and when tilted to the left, a



                      90     RoboGenius (V1.0)-V
   87   88   89   90   91   92   93   94   95   96   97