* 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>
1.6 KiB
On Pin Released
Start an event handler (part of the
program that will run when something happens, like when a button is
pressed). This handler works when you release pin 0
, 1
, or 2
together with GND
. When you are using this function in a web
browser, click and release the pins on the screen instead of the ones on the
@boardname@.
If you hold the GND
pin with one hand and touch pin 0
, 1
, or 2
with the other, a very small (safe) amount of electricity will flow
through your body and back into the @boardname@. This is called
completing a circuit. It's like you're a big wire!
input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Up, () => {
})
~hint
This function works best when the @boardname@ is using batteries for power, instead of the USB cable.
~
Parameters
name
means the pin that is being released, eitherP0
,P1
, orP2
Example: pin pressed counter
This program counts how many times you release the P0
pin.
Every time you release the pin, the program shows the number of times on the screen.
let count = 0
basic.showNumber(count, 100)
input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Up, () => {
count = count + 1
basic.showNumber(count, 100)
})
See also
@boardname@ pins, pin is pressed, analog read pin, analog write pin, digital read pin, digital write pin