Login

Please fill in your details to login.





micro:bit - tilt

This page is mainly about micro:bit - tilt
BL / PY : Using the game library, design a script which allows you to move a 'dot' around the screen by tilting the micro:bit forwards, backwards, left or right using gestures. Using the game library makes it easier to move the dot, though you could try and do it without the game library for a challenge!

BL / PY : The only issue is that you have to return the micro:bit to flat and reapply to gesture to keep the dot moving. Change your script so that dot with move as long as you hold the micro:bit in that direction and stop it moving if you return the micro:bit to 'face up'.

BL / PY : Now adapt your script so that you use the accelerometer x and y position to move your dot around the screen. I've found that limits of -200 and 200 seem to work quite well. Since the accelerometer will continually register the tilt of the micro:bit, it will keep moving whilst you are tilting the device so you might have to use pauses to slow things down a bit or else your dot will constantly end up on the edges of the screen!


Special Prize! Ask your teacher to give you a copy of some instructions to make a game called 'Catch me if you can' where you tilt your micro:bit to get your dot to try to catch a flashing ghost. You've got 30 seconds to get as many points as you can!

Last modified: August 3rd, 2022
The Computing Café works best in landscape mode.
Rotate your device.
Dismiss Warning