2018-08-23 11:47:36 -07:00
# Love Meter
2016-06-14 11:12:13 -04:00
2018-10-10 15:38:51 -07:00
## Introduction @unplugged
2017-12-06 20:23:17 -08:00
Make a love meter, how sweet! The @boardname @ is feeling the love, then sometimes not so much!
2018-10-10 15:38:51 -07:00
Tell everyone who you are. Show you name on the LEDs.
![Love meter banner message ](/static/mb/projects/love-meter/love-meter.gif )
2016-06-11 17:12:12 -04:00
## Step 1
2018-09-14 14:57:17 -07:00
Let's build a **LOVE METER** machine. Place an ``||input:on pin pressed||`` block to run code when pin **0** is pressed. Use ``P0` ` from the list of pin inputs.
2016-06-11 17:12:12 -04:00
```blocks
input.onPinPressed(TouchPin.P0, () => {
});
```
2018-08-17 07:58:45 -07:00
2016-06-11 17:12:12 -04:00
## Step 2
2018-09-14 14:57:17 -07:00
Using ``||basic:show number||`` and ``||Math:pick random||`` blocks, show a random number from ` 0` to ` 100` when pin **0** is pressed.
2016-06-11 17:12:12 -04:00
```blocks
input.onPinPressed(TouchPin.P0, () => {
2018-08-17 07:58:45 -07:00
basic.showNumber(Math.randomRange(0, 100));
2016-06-11 17:12:12 -04:00
});
```
## Step 3
2018-08-17 07:58:45 -07:00
Click on pin **0** in the simulator and see which number is chosen.
## Step 4
2017-09-11 10:49:40 -07:00
Show ``"LOVE METER"` ` on the screen when the @boardname @ starts.
2016-06-11 17:12:12 -04:00
```blocks
2017-09-11 10:49:40 -07:00
basic.showString("LOVE METER");
2016-06-11 17:12:12 -04:00
input.onPinPressed(TouchPin.P0, () => {
2018-08-17 07:58:45 -07:00
basic.showNumber(Math.randomRange(0, 100));
2016-06-11 17:12:12 -04:00
});
2016-06-25 17:22:50 -04:00
```
2017-09-11 10:49:40 -07:00
2018-08-17 07:58:45 -07:00
## Step 5
2017-09-11 10:49:40 -07:00
2018-08-17 07:58:45 -07:00
Click ``|Download|` ` to transfer your code in your @boardname @. Hold the **GND** pin with one hand and press pin **0** with the other hand to trigger this code.