Skip to content

Activity

Guitar 2 - chords

Advanced | MakeCode, Python | Pins, Sound | Electricity, Electronics, Harmony, Sequence, Sound

Step 1: Make it

What is it?

Make your micro:bit guitar or keyboard play chords with a single touch.

Headphones connected to pins 0 and GND, tin foil pads connected to pins 1, 2 and GND on micro:bit

How it works

  • The micro:bit can only play one note at a time, so it can’t play a real chord. It can, however, play a broken chord or arpeggio: take 3 notes from any chord and play them one after another and they will sound good together.
  • Wire up a micro:bit to headphones so you can hear sound.
  • Connect tin foil pads to the micro:bit's pins like in the Guitar 1 – Touch tunes project.
  • When you touch pin 1 it will play an F major broken chord, when you touch pin 2 it will play an A minor broken chord.

What you need

  • micro:bit and optional battery pack
  • headphones, buzzer or powered speaker
  • 5 crocodile clip leads
  • optional cardboard, tin foil, glue stick, scissors to make guitar or keyboard

Step 2: Code it

1from microbit import *
2import music
3
4while True:
5    if pin1.is_touched():
6        music.play(["F4:4", "A4", "C5"])
7    if pin2.is_touched():
8        music.play(["A4:4", "C5", "E5"])
9

Step 3: Improve it

  • Modify the program to play different chords, use the micro:bit’s buttons or gestures to add more than two.
  • Change the tempo to make the chords play faster. In MakeCode you can use the tempo blocks. In Python change the number in the first note: F4:4 means play F in the 4th octave for a duration of 4. Make the second 4 a smaller number and see what happens.
  • Use loops to keep the chords playing like an arpeggiator (a feature of some keyboards and synthesisers which causes an arpeggio to keep playing as long as a key is held down).