Lesson 4 – Glowing pendulum Bbc microbit Lesson 4 – Glowing pendulum hot
Glowing pendulum Use a forever block so that your program will continue to run. Set up a variable called acceleration and store the acceleration (y) of the Microbit into this variable, this will allow your to use the data stored from the acceleration later in your program.
Glowing pendulum Now we need to make sure the acceleration comes out with a positive value so we need to take the absolute value of the acceleration we use the Math abs code to do this, then of course enter the variable acceleration.
Glowing pendulum Divide the acceleration value by 4 because we want a value between 0 and 256 and the variable currently has a number stored between 0 and 1024.
Glowing pendulum Firstly set the brightness of the LED’s depending on how fast the Microbit is moving then turn them on.
Glowing pendulum Upload the code to your Microbit and see what happens when you move your Microbit like a pendulum. If you have forgotten how to upload go back and look at lesson 1 and 2.
Glowing pendulum Answer these questions in assessment tool, you must answer these before you move onto the extension challenges.
Glowing pendulum Extension Challenge 1 Answer this in assessment tool.