Monday, 8 August 2016

BBC micro:bit Egg Hatcher - Pokémon Go Style

The BBC micro:bit is a portable microprocessor with built in sensors and an LED matrix. It's perfect for building an egg-hatching pedometer in the style of Pokémon Go.

The actually distance counter in Pokémon Go uses GPS and has some accuracy issues (as we noted in our article on using Pokémon Go as a kids fitness tracker). This is a good project to get kids thinking about how Pokémon Go could be improved.

The BBC micro:bit has a built-in accelerometer and generates 'shake' events when it detects a significant movement. This has been used to create a pedometer.

We've adapted that idea to create a simple Pokémon Go style egg-hatcher. The script displays an egg animation until a target number of steps is reached and then an egg hatching animation is triggered and a random creature hatches.

If you're stuck indoors then you could do star jumps instead and set an appropriate target.


Here's a demo of how the project works. We've set it up to only need a few shakes for the demo, but once you've got it working you can set a higher target.

The Code

We used the Code the Micro:bit website to program our Egg Hatcher but you could also use one of the editors at the BBC micro:bit website. 

First, detect steps and display a "?" when the target is reached. Set a small target for testing, you can increase it later. 

You could just start with one monster and then add a choice of random monsters once you have that working.

You might want to tuck the micro:bit into a sock rather than holding it and you don't want to miss the animation so it will only run when the B button is pressed.


You'll need to change the number on the  'steps >' code when you increase the number of steps required to hatch an egg when you've finished testing.

We included 3 pixel monsters, but you could add more, just change the second number in the 'pick random' to one less than the number of monsters you have.

Progress Checker 

Want to know how many steps you've walked so far? You can add code to display the number of steps walked so far when you press the A button.


There's lots more you could do to handle the A and B buttons being pressed after the egg has hatched, but this gives you a basic useful program that can be used. 

More from Tech Age Kids:


Luke H said...

This is fab! I can't wait to give it a go!

Tracy said...

Thanks Luke. I think Pokémon Go is going to feature quite a bit in my teaching this year!

Post a Comment