BBC micro:bit – Gold Rush!

Gold MinerDuring a gold rush, gold miners use different techniques to find traces of gold hidden in the ground. One technique that miners use is gold panning. It consists of scooping some gravels and clear water in a pan which is gently agitated until small gold nuggets sinks to the bottom of the pan and can be handpicked.

For this challenge the pan will be the micro:bit. A LED light will represent a gold nugget. The aim is to tilt the micro:bit slightly to detect and pick up the gold nugget.

We will be using the built-in accelerometer sensor to detect in which direction the microbit is being tilted.
Every time the player (miner) will pick a gold nugget a new one will randomly appear on the 5 x 5 LED screen.


Complete Code

Use the BBC microbit website to complete the code:


Code Review

Checking the code above answer the following questions:

  • Can you identify the block of code used for the micro:bit to detect if it has been tilted to the left?
  • Can you identify the block of code used for the micro:bit to know when the miner has picked up a gold nugget?
  • Can you explain how does the micro:bit decide to stop the game by running the last block to display the Game Over message?

Extension Task

Change this game to use a timer. The game should last exactly 1 minute. Everytime the player picks up a gold nugget their score should increment by 1. After 1 minute, the game should stop and display the total score.

Ideas to get started

  1. You could use a variable called “timer” and set it to 60000ms.
  2. You could decrement your timer variable when the game is paused.
  3. You will have to change the condition of your while loop: Instead of while score<10, use while timer>0.
  4. Make sure that you display the final score at the end of the game.


The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 3.7 / 5. Vote count: 18

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: