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() {})