Love Meter

Introduction

Make a love meter, how sweet! The Calliope mini is feeling the love, then sometimes not so much!

Love meter banner message

Step 1

Let’s build a LOVE METER machine. We’ll use an ||input:on pin pressed|| block to run code when pin 0 is pressed. Use P0 from the list of pin inputs.

input.onPinTouchEvent(TouchPin.P0, input.buttonEventValue(ButtonEvent.Down), () => {
});

Step 2

Using ||basic:show number|| and ||Math:pick random|| blocks, show a random number from 0 to 100 when pin 0 is pressed.

input.onPinTouchEvent(TouchPin.P0, input.buttonEventValue(ButtonEvent.Down), () => {
    basic.showNumber(randint(0, 100));
});

Step 3

Click on pin 0 in the simulator and see which number is chosen.

Step 4

Show "LOVE METER" on the screen when the Calliope mini starts.

basic.showString("LOVE METER");
input.onPinTouchEvent(TouchPin.P0, input.buttonEventValue(ButtonEvent.Down), () => {
    basic.showNumber(randint(0, 100));
});

Step 5

Click |Download| to transfer your code in your Calliope mini. Hold the GND pin with one hand and press pin 0 with the other hand to trigger this code.