Love Meter

Learn how to use the device's input pins in this activity!

  • Get started
  • MakeCode
  • Pins
  • Inputs
Print lesson
  • Ages 8+
  • 30 mins
  • MakeCode Editor


This project uses the input pins on the micro:bit to control the output on the LED screen.

Teacher Guide

Open Open teacher resources


4 steps

Step One

Let's build a LOVE METER machine. Place an on pin pressed block to run code when pin P0 is pressed.

input.onPinPressed(TouchPin.P0, function () {

Step Two

Using show number and pick random blocks, show a random number from 0 to 100 when pin P0 is pressed.

input.onPinPressed(TouchPin.P0, function () {
    basic.showNumber(Math.randomRange(0, 100))

Step Three

Show "LOVE METER" on the screen when the micro:bit starts.

basic.showString("LOVE METER")

Step Four

Click Download to transfer your code in your micro:bit. Hold the GND pin with other hand and press pin P0 with the other hand to trigger this code.


Try to add the following functionality:

  • Allow the students access to real world components to build up their own circuits using the input pins; a number of examples can be found here.

Learn More

The 'Smiley Buttons' activity uses the radio frequency block to send and receive data between two micro:bits.

Selecting this opens external content from our support system, which adheres to their privacy policy.