Lesson 5 – Reflexes

Learning Outcomes



Create working reflex test.  Copy code, flash it to the micro:bit, and test it.


Amend and improve the provided code, improving the program


Amend and improve the provided code, improving the program.  Annotate the code carefully making sure the code is described.

Extend the program substantially.


Words to learn for this lesson are: Gamification, variable, iteration


Work in pairs.  Person A, get your phone out.  Person B, must take a ruler, and place it on the edge of the table. Person B must knock the ruler off the edge of the table, and then catch it.  WITH THE SAME HAND.  Person A times this using a Stopwatch app.

After making a note of the time taken to catch the ruler, this must be repeated 5 times.  The median of this score is to be worked out.   Who has the fastest reflexes in the group?


You’ll need the code listing found >>here<< .

Type the full code into the micro:bit using the micropython editor.

Make sure you carefully test and review the code.  It must work flawlessly.

Run the program a few times.  Why is this more accurate than our “ruler” method?


  1. Comment the code thoroughly to show how it works.
  2. How did we measure the median before?  Could you change the code so it gives you the median of the number of goes?  Hint: You’ll need two variables, median and numberOfGoes BEFORE thew loop starts.   They must both be updated inside the loop.
  3. Can you make a way to reset the median?  Maybe button a to continue, button b to reset?
  4. Print out your finished code. Make sure it is recorded  in your book.


Is there a way you could “Gamify” this? (Turn it into a game).  How would you change the code?

Your teacher will quickly find the fastest microbit in the class!!