Love Meter
Introduction
How much love ๐ are you emitting today? Create a ๐ LOVE METER ๐ machine with your micro:bit!

Step 1
Weโll use this ||input:on pin pressed|| block to run code when pin 0 on the micro:bit is pressed. From the ||basic:Basic|| Toolbox category, drag a ||basic:show number|| block and drop into the ||input:on pin pressed|| block.
input.onPinPressed(TouchPin.P0, function() {
//@highlight
basic.showNumber(0)
})
Step 2
From the ||math:Math|| category, get a ||Math:pick random|| block and drop it into the ||basic:show number|| block replacing 0.
input.onPinPressed(TouchPin.P0, function() {
//@highlight
basic.showNumber(randint(0, 100))
})
Step 3
Now letโs be sure to label our Love Machine! From the ||basic:Basic|| Toolbox category, drag an ||basic:on start|| block and drop it anywhere on the Workspace. Then get a ||basic:show string|| block and place it in the ||basic:on start|| block. Type the words โLOVE METERโ into the ||basic:show string|| block.
//@highlight
basic.showString("LOVE METER")
input.onPinPressed(TouchPin.P0, function() {
basic.showNumber(randint(0, 100))
})
Step 4
Letโs test our code. Press Pin 0 on the micro:bit on-screen simulator (bottom left). Numbers between 0-25 = ๐ค No Love, 26-50 = ๐ซถ BFF Love, 51-75 = ๐ Brokenhearted Love, 76-100 = ๐๐ฅ Fiery Hot Love!
Step 5
If you have a micro:bit device, connect it to your computer and click the |Download| button. Follow the instructions to transfer your code onto the micro:bit. Once your code has been downloaded, hold the GND pin with one hand and touch the 0 pin with the other hand. Your micro:bit ๐ LOVE METER ๐ machine will detect the love current flowing through your body!
randint(0, 100)
# BlocksExistValidator
input.onPinPressed(TouchPin.P0, function() {})