pxt-calliope/docs/projects/love-meter.md
Juri Wolf a93febb5b7
Map and clean deprecated functions (#175)
* add image and deprecated arrow functions

* update locales

* map basic.showArrow

* map arrow blocks

* map & remove arrow images

* remove arrow blocks

* update locales

* remove & patch:
rgbw -> rgb
button/pin pressed -> button/pin event
loudness -> soundLevel

* update ts mappings for arrows

* add wip ts patch rules

* update .blocks files

* use Click instead of Down as default in Documentation and tests

* patch test.blocks

* fix lowercase name tag

* update test.blocks

* update blocks test files

* update blocks test files

* format block files

* pass blocks file tests

* fix ts mapping

* fix color.defl value

closes https://github.com/microsoft/pxt-calliope/issues/136

* fix ts mappings

- add optional spacing at the end of rgbw()
- map up to v4.0.19

* add suggested changes

* replace innerText by textContent

Co-authored-by: JW <gitkraken@juriwolf.de>
Co-authored-by: Juri <info@juriwolf.de>
2022-04-26 10:28:42 -07:00

1.2 KiB

Love Meter

Introduction @unplugged

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

Love meter banner message

Step 1

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.

input.onPinTouchEvent(TouchPin.P0, 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, 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 @boardname@ starts.

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

Step 5

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.