So here's my confession. I have a bit of a 'thing' going on about gyroscopes.

For years I'd forgotten about those spinning tops balancing on pencils, pens, even a string tightrope!

But one morning recently, they just popped into my head again.

I wanted to remind myself of how they worked, the physics involved. So I went online and found out. But that wasn't enough to get the brain worm out of my head. I had to make one.

Bits of an old hard drive, a DC motor from a cassette tape drive, some wire & glue, a 12V battery and there I had it... my very own electric gyroscope.


The fascination waned quickly though. There are only so many times the family will look at a spinning thing standing up by itself on a table! I had to move on.

It occurred to me that inside every smartphone there are accelerometers that are combined to provide gyroscopic functions for some games and other apps.

How do they get the big spinning things inside a smartphone? I had to find out.

Turns out it's done using a chip called a MEMS device. Micro Electro Mechanical System. Inside are micron sized tuning forks oscillating at high frequencies. When the chip is rotated or experiences acceleration, the tuning forks distort by differing amounts, changing their frequencies which are measured and converted into numerical values. Clever eh?

So what does all this have to do with the micro:bit ?

The micro:bit has a triple-axis accelerometer MEMS chip onboard and I thought it would be fun to apply my obsession with gyroscopes and see what I could make the micro:bit do.

The result is I have made the digital equivalent of the ball bearing puzzle game... the one where you have a ball bearing in a box and you have to get it in the centre hole of the puzzle by carefully tilting the box around to move the ball.

Using the LED display of the micro:bit, a single LED lights up and is moved by tilting the micro:bit in different directions.

By pressing the A button a few times you make the game easier... less sensitive to movement.

By pressing the B button a few times you make the game harder... more sensitive to movement.





To keep things simple and accessible for all, I used the Microsoft PXT editor (www.pxt.io) to write the code.

Download the hex file attached here, then drag & drop it onto the PXT coding screen to open the code.



Here's an explanation of the code:


I tend to show students the big spinning gyroscope first, then explain to them how such a thing can be squeezed into a smartphone. I show them the game and the code behind it. The discussion can cover electro-mechanical engineering, the physics of balancing, microelectronics and miniaturisation, coding, and the many day-to-day applications these technologies are used for.

I hope you find this useful, or at least a bit of fun!