As the whole of the United Kingdom is celebrating the Queen’s Platinum Jubilee in 2022, we’ve put together a fun and easy project to try with your family during the platinum jubilee bank holiday weekend.
We’ve programmed the BirdBrain Technologies Finch Robot 2.0 and the BBC micro:bit to draw the Union Jack and play the British National Anthem, “God Save the Queen”.
This beginner-level project has only a few steps, doesn’t require many tools, and takes about half an hour to complete. It’s perfect for having fun with the family and learning some basics of Python programming and robotics.
Here’s Sophie explaining the steps we need to take to successfully complete the project and some tips on how to best make it work:
4. Go to https://brython.birdbraintechnologies.com/useBrython.html
5. Click on “Find robots”.
Ensure your Bluetooth is on.
6. Select the Bluetooth device, and you will see the following screen to confirm you are paired to your Finch.
7. Press the play icon; then, you will see “hello” flash across the Finch.
Now we are going to code the Finch to move in the Union Jack main cross-movement:
1. Disconnect the Finch from the USB and turn the Finch on by pressing the button underneath it.
2. Reconnect the Finch; this time, you will see a different symbol:
3. Import the finch library using:
from BirdBrain import Finch
4. Declare a Finch object; in this case, I will call mine Finchey:
finchey = Finch(‘A’)
5. Set variables for the sizes you want and the speed. Try to put a low speed to allow the pen to make a mark on the paper when you use it:
longerSize = 25
shorterSize = 15
widthSize = 5
speed = 20
6. Create a function to draw one quarter of the flag:
def draw(A,B):
finchey.setMove(‘F’,A,speed)
finchey.setTurn(‘L’,90,50)
finchey.setMove(‘F’,B,speed)
finchey.setTurn(‘R’,90,50)
finchey.setMove(‘F’,widthSize,speed)
finchey.setTurn(‘R’,90,50)
7. Create a function to draw the flag calling your previous function:
def drawFlag():
draw(longerSize,shorterSize)
draw(shorterSize,longerSize)
draw(longerSize,shorterSize)
draw(shorterSize,longerSize)
8. Call the function:
drawFlag()
9. Your code will look like the below. Press the play button to test the Finch moves, put a pen inside the Finch and on a bit of paper, and he will draw a cross:
Next, we will program the national anthem, “God Save the Queen”.
def lightupTail():
randomnum = random.randint(1,99)
randomnum2 = random.randint(1,99)
randomnum3 = random.randint(1,99)
finchey.setTail(“all”,randomnum,randomnum2,randomnum3)
notesToPlay = {“C”:60, “C#”:61, “D”:62, “D#”:63, “E”:64, “F”:65, “F#”:66, “G”:67, “G#”:68, “A”:69, “A#”:70, “B”:71, “HighC”:72, “HighD”:74}
OneBeat = 0.5
Halfbeat = OneBeat/2
ExtendedBeat = OneBeat * 1.33
TripleBeat = 3
def playNotes(note,beat):
print(“Note “,note,” beat “,beat)
finchey.playNote(notesToPlay[note],beat)
sleep(0.5)
Finally, we will call the playNotes() function, playing all notes in the anthem and separating them by bar. We will put them in a playAnthem() function so that we can call them all at once:
def playAnthem():
print(“### Bar1 ###”)
lightupTail()
playNotes(‘F’, OneBeat)
playNotes(‘F’, OneBeat)
playNotes(‘G’, OneBeat)
print(“### Bar2 ###”)
lightupTail()
playNotes(‘E’, ExtendedBeat)
playNotes(‘F’, Halfbeat)
playNotes(‘G’, OneBeat)
print(“### Bar3 ###”)
lightupTail()
playNotes(‘A’, OneBeat)
playNotes(‘A’, OneBeat)
playNotes(‘A#’, OneBeat)
print(“### Bar4 ###”)
lightupTail()
playNotes(‘A’, ExtendedBeat)
playNotes(‘G’, Halfbeat)
playNotes(‘F’, OneBeat)
print(“### Bar5 ###”)
lightupTail()
playNotes(‘G’, OneBeat)
playNotes(‘F’, OneBeat)
playNotes(‘E’, OneBeat)
print(“### Bar6 ###”)
lightupTail()
playNotes(‘F’, OneBeat)
playNotes(‘F’, Halfbeat)
playNotes(‘G’, Halfbeat)
playNotes(‘A’, Halfbeat)
playNotes(‘A#’, Halfbeat)
print(“### Bar7 ###”)
lightupTail()
playNotes(‘HighC’, OneBeat)
playNotes(‘HighC’, OneBeat)
playNotes(‘HighC’, OneBeat)
print(“### Bar8 ###”)
lightupTail()
playNotes(‘HighC’, ExtendedBeat)
playNotes(‘A#’, Halfbeat)
playNotes(‘A’, OneBeat)
print(“### Bar9 ###”)
lightupTail()
playNotes(‘A#’, OneBeat)
playNotes(‘A#’, OneBeat)
playNotes(‘A#’, OneBeat)
print(“### Bar10 ###”)
lightupTail()
playNotes(‘A#’, ExtendedBeat)
playNotes(‘A’, Halfbeat)
playNotes(‘G’, OneBeat)
print(“### Bar11 ###”)
lightupTail()
playNotes(‘A’, OneBeat)
playNotes(‘A#’, Halfbeat)
playNotes(‘A’, Halfbeat)
playNotes(‘G’, Halfbeat)
playNotes(‘F’, Halfbeat)
print(“### Bar12 ###”)
lightupTail()
playNotes(‘A’, ExtendedBeat)
playNotes(‘A#’, Halfbeat)
playNotes(‘HighC’, OneBeat)
print(“### Bar13 ###”)
lightupTail()
playNotes(‘HighD’, Halfbeat)
playNotes(‘A#’, Halfbeat)
playNotes(‘A’,OneBeat)
playNotes(‘G’,OneBeat)
print(“### Bar14 ###”)
lightupTail()
playNotes(‘F’,TripleBeat)
print(“### Bar15 ###”)
lightupTail()
playNotes(‘F’,OneBeat)
playNotes(‘F’,OneBeat)
playNotes(‘G’,OneBeat)
print(“### Bar16 ###”)
lightupTail()
playNotes(‘E’,ExtendedBeat)
playNotes(‘F’, Halfbeat)
playNotes(‘G’,OneBeat)
print(“### Bar17 ###”)
lightupTail()
playNotes(‘A’,OneBeat)
playNotes(‘A’,OneBeat)
playNotes(‘A#’,OneBeat)
print(“### Bar18 ###”)
lightupTail()
playNotes(‘A’,ExtendedBeat)
playNotes(‘G’, Halfbeat)
playNotes(‘F’,OneBeat)
print(“### Bar19 ###”)
lightupTail()
playNotes(‘G’,OneBeat)
playNotes(‘F’,OneBeat)
playNotes(‘E’,OneBeat)
print(“### Bar20 ###”)
lightupTail()
playNotes(‘F’,OneBeat)
playNotes(‘F’, Halfbeat)
playNotes(‘G’, Halfbeat)
playNotes(‘A’, Halfbeat)
playNotes(‘A#’, Halfbeat)
print(“### Bar21 ###”)
lightupTail()
playNotes(‘HighC’,OneBeat)
playNotes(‘HighC’,OneBeat)
playNotes(‘HighC’,OneBeat)
print(“### Bar22 ###”)
lightupTail()
playNotes(‘HighC’,ExtendedBeat)
playNotes(‘A#’,Halfbeat)
playNotes(‘A’,OneBeat)
print(“### Bar23 ###”)
lightupTail()
playNotes(‘A#’,OneBeat)
playNotes(‘A#’,OneBeat)
playNotes(‘A#’,OneBeat)
print(“### Bar24 ###”)
lightupTail()
playNotes(‘A#’, ExtendedBeat)
playNotes(‘A’,Halfbeat)
playNotes(‘G’,OneBeat)
print(“### Bar25 ###”)
lightupTail()
playNotes(‘A’,OneBeat)
playNotes(‘A#’,Halfbeat)
playNotes(‘A’,Halfbeat)
playNotes(‘G’,Halfbeat)
playNotes(‘F’,Halfbeat)
print(“### Bar26 ###”)
lightupTail()
playNotes(‘A’, ExtendedBeat)
playNotes(‘A#’, Halfbeat)
playNotes(‘HighC’,OneBeat)
print(“### Bar27 ###”)
playNotes(‘HighD’, Halfbeat)
playNotes(‘A#’, Halfbeat)
playNotes(‘A’,OneBeat)
playNotes(‘G’,OneBeat)
print(“### Bar288 ###”)
playNotes(‘F’,TripleBeat)
drawFlag()
playAnthem()
Lay four bits of paper down with masking tape in between so that no ink goes off the paper. Put your pen in the Finch Robot, preferably a paint pen. Then place the Finch at the edge of the paper as I have done in the video. Now press play on your code to see the Finch draw a cross and then play the national anthem.
You’ve successfully completed this Queen’s Jubilee project using the Finch Robot and the BBC micro:bit board. Why not share your result with us on social channels? Tag us – @letsokdo!
Visit our BBC micro:bit shop and discover more amassing products for your next project!
Ready to jump on your next project? Find some inspiration on our Projects Hub.
From a quick tap to smashing that love button and show how much you enjoyed this project.