Welcome to the DFRobot blog
:
www.dfrobot.com/blog-tag-microbit.html
59
/
86
STEP 2: All the LEDs are starting turned off, which means the initial value of the variable "the number
of LEDs to be lit" should be set to 0. Then, we will use a loop function to make the variable getting
larger by 1 in each loop. Also, to make sure that the total number of the LED never exceeds 7, we
will need to setup the initial condition by using “while do” function.
Use the logic operator “<” to set the condition, we will have: when "the number of LEDs to be lit" is
less than 7, the “while do” loop will make the LED light up 1 by 1 until all the LEDs are turned on. By
putting all above listed function together, the final program goes as:
STEP 3: Now, the rest we need to do is to make the parameter getting larger by 1 in every loop.
However, we don't want this happen too quickly, a “rest” function may help us slow it down. The
flow chart below may be helpful in helping us figure out what the program looks like: