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:

Step 1: Unbox the Finch

  1. Unpack the contents of the Finch Robot 2.0 (as I have in video 1)
  2. Insert your micro:bit into the tail as I showed in the video above
  3. Insert the USB connector into the micro:bit and into the computer.

Step 2: Connect the Finch to the computer

4. Go to https://brython.birdbraintechnologies.com/useBrython.html

5. Click on “Find robots”.

Image showing the Finch Robot's setup

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.

Image showing the Finch robot's setup

7. Press the play icon; then, you will see “hello” flash across the Finch.

Step 3: Program the Finch to move

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:

Image showing the Finch robot's setup

Step 4: Program the Finch to play the national anthem

Next, we will program the national anthem, “God Save the Queen”.

  1. Firstly, create a function that will randomly light up Finchey’s tail. We will use this to set the colours to change when they play a new bar from the music. The function setTail() tells the Finch to set all LEDs on the tail to a certain colour based on a mixture of colours for RGB values.

def lightupTail():
randomnum = random.randint(1,99)
randomnum2 = random.randint(1,99)
randomnum3 = random.randint(1,99)
finchey.setTail(“all”,randomnum,randomnum2,randomnum3)

  1. Next we will create a dictionary of the notes that the Finch can play, ** explain these are from midi scale and finche use numbers**:

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}

  1. Next, we will set our beats values:

OneBeat = 0.5
Halfbeat = OneBeat/2
ExtendedBeat = OneBeat * 1.33
TripleBeat = 3

  1. We will then create a function to play notes for a corresponding beat:

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)

  1. Finally, add the final code to your code to firstly draw the cross and then play the national anthem:

drawFlag()
playAnthem()

Step 5: Set up drawing space

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.

Summary

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!

BBC micro:bit shop on OKdo

Visit our BBC micro:bit shop and discover more amassing products for your next project!

Image about the BBC micro:bit shop on okdo.com

Projects Hub

Ready to jump on your next project? Find some inspiration on our Projects Hub.Screenshot of the Projects Hub on OKdo

Like what you read? Why not show your appreciation by giving some love.

From a quick tap to smashing that love button and show how much you enjoyed this project.

Privacy

Our website uses cookies and similar technologies to provide you with a better service while searching or placing an order, for analytical purposes and to personalise our advertising. You can change your cookie settings by reading our cookie policy. Otherwise, we’ll assume you’re OK with our use of cookies.

Location

Please select an option to see content specific to your location and shop online.

Browse the US site