Microbit Sensors & Circuits
Intermediate
60 mins
Teacher/Student led
215 points
What you need:
Chromebook/Laptop/PC
Microbit
Crocodile clips
Some fruit & vegetables

Microbit Fruit and Veg Piano

Discover the electrical conductivity of your body and various fruits and vegetables in this interactive project. You'll create a musical circuit using a Microbit, crocodile clips, and your chosen produce. By following step-by-step instructions, you'll learn to program your Microbit, test your circuits, and finally play your fruit and veg piano.
Learning Goals Learning Outcomes Teacher Notes Lesson Files

Live Class Feed

This is a live feed of the latest activity by your students on this lesson. It will update in real-time as they work on the lesson.
Load previous activity

    1 - Introduction

    Did you know that your body can conduct electricity? In fact lots of things can conduct electricity, some better than others.

    In this project we're going to create an electrical circuit using your body and some fruit and vegetables (which also can conduct electricity) to make your Microbit create some music.

    Don't worry this is safe to do, as the amount of electricity we'll be using is very, very low.

    Never play with or do experiments with high powered electricity such as plugs and power outlets. This level of electricity is actually dangerous!

    2 - What you need

    For this project you will need:

    1. A microbit 
    2. 4 Crocodile clips
    3. 4 pieces of fruit or vegetables such as bananas, apples, carrots etc.

    3 - Create a new Microbit project

    Go to the makecode.microbit.org website and create a new project.

    4 - Program Pin 0

    Microbits have 3 "pins" on them (P0, P1 & P2) that can be used with the GND (ground) pin to create circuits. In a later step we will be attaching the crocodile clips to these pins but for now lets add some come to program what will happen when the circuit is completed.

    Add the following code to program P0. You can choose any note or icon you want.

    basic.forever(function () {
        if (input.pinIsPressed(TouchPin.P0)) {
            music.playTone(262, music.beat(BeatFraction.Quarter))
            basic.showIcon(IconNames.Happy)
        }
    })
    

    5 - Program Pin 1

    Add the following code to program P1. You can choose any note or icon you want, just make them different to P0 and P2.

    basic.forever(function () {
        if (input.pinIsPressed(TouchPin.P0)) {
            music.playTone(262, music.beat(BeatFraction.Quarter))
            basic.showIcon(IconNames.Happy)
        }
        if (input.pinIsPressed(TouchPin.P1)) {
            music.playTone(392, music.beat(BeatFraction.Quarter))
            basic.showIcon(IconNames.Angry)
        }
    })
    

    Unlock the Full Learning Experience

    Get ready to embark on an incredible learning journey! Get access to this lesson and hundreds more in our Digital Skills Curriculum.

    Copyright Notice
    This lesson is copyright of Coding Ireland. Unauthorised use, copying or distribution is not allowed.
    🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more