Skip to content


Guitar 1 - touch tunes

Advanced | MakeCode, Python | Pins, Sound | Electricity, Electronics, Input/output, Sound

Step 1: Make it

What is it?

The first step to making a micro:bit guitar: play different tunes by using the micro:bit’s touch sensor.

These two videos show you what you'll make and how to code it:


Coding guide

How it works

  • This is like the Jukebox project, but instead of using the micro:bit’s buttons, you’ll make your own input device, touch buttons using crocodile clip leads and tin foil connected to the micro:bit's pins.
  • Flash the program on to your micro:bit. Attach headphones to pin 0 and GND so you can hear sound – see Make some noise project for details.
  • Attach crocodile clips to pins 1, 2 and another to GND. With one finger touch GND, and with another finger touch the wires connected to pin 1 and then pin 2. It should play a different tune depending on which pin you touch.
photo showing how to connect silver foil pads to micro:bit pins 1, 2 and GND
  • The micro:bit is using pin 0 as an analogue output, varying the electrical signal to make audio (sound). It’s using pins 1 and 2 as touch inputs. When you touch either of these pins and the GND (ground or Earth) pin, you’re completing an electrical circuit. A small amount of electricity flows through you and the micro:bit can detect it and the program triggers the playing of a tune.

What you need

  • micro:bit and optional battery pack
  • MakeCode or Python editor
  • 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
4while True:
5    if pin1.is_touched():
7    if pin2.is_touched():

Step 3: Improve it

  • Make touch buttons using tin foil and cardboard. Shape them to look like a keyboard or a guitar.
  • Change the tunes that get played when you touch the tin foil.
  • Program your own tunes.