2016-06-14 17:12:13 +02:00
|
|
|
# love meter
|
|
|
|
|
2017-09-07 22:42:08 +02:00
|
|
|
## ~avatar avatar
|
2016-06-11 23:12:12 +02:00
|
|
|
|
2016-11-10 17:37:13 +01:00
|
|
|
Use pins and your body to change the display!
|
|
|
|
|
2017-09-07 22:42:08 +02:00
|
|
|
## ~
|
2016-06-11 23:12:12 +02:00
|
|
|
|
|
|
|
## Step 1
|
|
|
|
|
|
|
|
Use [on pin pressed](/reference/input/on-pin-pressed) to show a random number
|
|
|
|
when pin P0 is pressed (hold the GND pin with other hand):
|
|
|
|
|
|
|
|
```blocks
|
|
|
|
input.onPinPressed(TouchPin.P0, () => {
|
|
|
|
basic.showNumber(Math.random(11));
|
|
|
|
});
|
|
|
|
```
|
|
|
|
## Step 2
|
|
|
|
|
|
|
|
Show a string when pin P1 is pressed:
|
|
|
|
|
|
|
|
```blocks
|
|
|
|
input.onPinPressed(TouchPin.P0, () => {
|
|
|
|
basic.showNumber(Math.random(11));
|
|
|
|
});
|
|
|
|
input.onPinPressed(TouchPin.P1, () => {
|
|
|
|
basic.showString("LOVE?");
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
## Step 3
|
|
|
|
|
|
|
|
Show a heart when pin P2 is pressed:
|
|
|
|
|
|
|
|
```blocks
|
|
|
|
input.onPinPressed(TouchPin.P0, () => {
|
|
|
|
basic.showNumber(Math.random(11));
|
|
|
|
});
|
|
|
|
input.onPinPressed(TouchPin.P1, () => {
|
|
|
|
basic.showString("LOVE?");
|
|
|
|
});
|
|
|
|
input.onPinPressed(TouchPin.P2, () => {
|
|
|
|
basic.showLeds(`
|
|
|
|
. # # # .
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
. # # # .
|
|
|
|
. . # . .
|
|
|
|
`);
|
|
|
|
});
|
2016-06-25 23:22:50 +02:00
|
|
|
```
|