Roll a ball around with your micro:bit.

First you need to create a variable called ‘y’ which uses an if statement to find out and store where on the y axis of your display the ball should go.

microbit1

Now you need to do the same again with a variable called ‘x’.

microbit2

Then you clear the display and create a dot where the variables ‘y’ and ‘x’ tell you to.

microbit3

 

Next you wrap the entire thing in a forever loop.

microbit4.PNG

 

Download your code to your micro:bit.

Now you can roll your ball around by tilting the micro:bit!

Advertisements