Doctor Who and the micro:bit - Mission Hack
Teachers! Before you continue, download the lesson plan, hand-outs and presentation slides for this mission here!
So here it is, the final mission from the Doctor. I don't know about you, but I'm totally nervous...
I've already created a link to the Dalek Spaceship computer network and the Doctor has prepared a fake Dalek with a micro:bit installed inside. We'll be connecting to that micro:bit remotely to navigate the spaceship without having to go ourselves. It's a super smart plan, in my opinion.
Clicking the link below will start the mission. We've framed it as a video game but I assure you it's totally a state-of-the-art hacking interface. Totally.
It will take all your knowledge of both the PXT and Python editors to navigate the maze-like hallways of the Dalek spaceship. Keep calm, think logically and I'm sure you'll be able to save the day.
When you're super famous from having saved the universe, think of your old AI buddy MICROBIT, won't you?
(The game will open in a separate browser window)
Make your own micro:bit Mazes
Have you beaten the mission? Congratulations, if so! We have an additional challenge for you to try if you're up for it.
All the mazes we navigated with our hacked Dalek were within grids of 5x5... just like the number of LEDs on a micro:bit.
This means that you can draw your own mazes for other people to solve on their micro:bit by coding the right instructions.
To draw your own maze, take a thick or coloured pen and draw walls to separate the cells of the maze, and decide on a start and an end point.
Solving the maze changes a little depending on which editor you're using.
There's a whole section of blocks perfect for this challenge! Under the Advanced tab there's another section called Game. Here, you can create a variable and make it a Game sprite, a single LED that can move between different LEDs on the micro:bit.
Below is an example of using the Game blocks to move an LED around the micro:bit. Remember to use loops and If statements, just like in the Dalek Hack mission, to make more moves in fewer lines of code.
Python doesn't have an equivalent to the 'Game' functions in PXT, but you can remember where the LED you've set is by using 'for loops'.
A 'for loop' looks a like this:
for y in range (4,0,-1):
display.set_pixel(0, y, 9)
The loop is setting up a variable ('y') counting from one number to another (from 4 to 0) in a number of steps (-1, so it's counting backwards one step at a time). Each time it takes a step, it executes the commands underneath it. In this case it lights up a pixel at coordinates 0,y at brightness 9.
Below is an example of using Python to move an LED around the micro:bit. Remember to use loops and If statements, just like in the Dalek Hack mission, to make more moves in fewer lines of code.