Step 4 – Code it up!

Step 5 – The real challenge – calibration.

Calibrate your dragon to make sure it’s flying back and forth in the sky and not face flat into the ground repeatedly.

With your servo firmly in place – code the micro:bit to turn your servo to 0 deg when button A is pressed, and to turn to 180 deg when button B is pressed.

Place a servo arm onto the head of the servo after pressing button A and watch to see where it goes when you press button B. If the servo arm points too far down or to the side, adjust the arm and reduce the angle coded. (e.g. adjust 0 – 180 deg to 20 – 160 deg)

Replace the servo arm with the dragon arm at the same angle and screw it down to secure it.

Step 6 – Calibration Part 2

On to the light sensor. We’ve got to capture the current light levels and when a laser passes over, the sensor will alert the micro:bit that the light levels has suddenly gone way up.

Thread the light sensor through the hole under the pop-up and to the front of the box.

Place the light sensor into the dragon’s mouth and tape it down to secure it.

Code the micro:bit to detect the light level through the light sensor when a button is pressed.

Step 7 – Putting it all together.

Now we want to be able to stop the dragon when it gets hit and also score points!

So we should combine the two pieces of code and use an IF logic block to check if we got hit.

IF we get hit, then we change the icon on the micro:bit and pause for a while, before changing back to the default icon.

ELSE (if we don’t detect and hits) then we allow the servo to move as per normal.

Also – add in more blocks so when the dragon gets hit it increases a score variable.

Cool stuff!

You’ve killed the dragon. Now what? Add extra mountains, make it more challenging. Or write your own story, and see what you can do with your magical micro:bit!

Let us know @tinkercademy on twitter, instagram or facebook what other cool stuff you come up with!

We're Done!

Looking for more projects to tinker and explore? We're a launch partner for IMDA's Digital Maker Programme, where we've been developing micro:bit kits, apps, and conducting workshops for schools and the public in Singapore. Read more here, and get in touch if you'd like to join our workshops!

About Tinkercademy

We’re coders and tinkerers who teach coding and tinkering to schools, corporations, and the public in Singapore. We bring an unparallelled depth of experience in education and technology to our classes and curriculum.