pxt-calliope/docs/lessons/love-meter.md

41 lines
998 B
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# love meter blocks lesson
create a love meter with the BBC micro:bit #pin #pressed #string #if #var #pause #show #docs
### @video td/videos/love-meter-0
## Topic
On Pin Pressed
## Quick Links
* [activity](/microbit/lessons/love-meter/activity)
* [quiz](/microbit/lessons/love-meter/quiz)
* [quiz answers](/microbit/lessons/love-meter/quiz-answers)
* [challenges](/microbit/lessons/love-meter/challenges)
## Prior learning/place of lesson in scheme of work
Learn how to use the **pin pressed**, `on pin pressed` to run code when the user holds the GND pin with one hand, and presses pin 0 with the other hand, thus completing a circuit. We will be learning how to create a love meter using input on pin pressed, a local variable, math random, If (conditional) as well as simple commands, such as show number, pause, and show string.
## Documentation
2016-03-30 00:59:00 +02:00
```docs
if (true) {
2016-03-26 00:47:20 +01:00
2016-03-30 00:59:00 +02:00
}
2016-03-26 00:47:20 +01:00
2016-03-30 00:59:00 +02:00
input.onPinPressed(TouchPin.P0, () => {
2016-03-26 00:47:20 +01:00
2016-03-30 00:59:00 +02:00
})
let x = 0
Math.random(3)
basic.showNumber(0)
basic.pause(100)
2016-03-26 00:47:20 +01:00
2016-03-30 00:59:00 +02:00
```