pxt-calliope/docs/projects/smiley-buttons.md
Amerlander 3fcd625555 Fix Image the second ()
* 2.0.1

* Pointing beta-ref to v2

* Bumping pxt-core to 5.15.10

* 2.0.2

* this repo is empty ()

* Update radio event parm usage descriptions ()

* add browser db prefix for v2 ()

* 2.0.3

* Releasing 2.0.3 to live ()

* dynamically sniff offline app version ()

* Revert "dynamically sniff offline app version ()" ()

This reverts commit b480b34f7e.

* Updating electron to 2.0.3 ()

* Updating offline reference to 2.0.3 ()

* Bumping version to 2.1.0

* 2.1.1

* Spelling ()

* Update write-received-packet-to-serial.md ()

A support ticket pointed out issues that they'd encountered when trying to follow this document:

- `sendValue` only supports an 8 character string. This is documented in the `sendValue` docs but a longer string had been used here
- Only `radio.onReceivedNumber` is used so the sample output is not consistent with the users experience. I've changed it so that all packets are handled

* Use gcPreAllocateBlock() to fix ,  ()

* Use gcPreAllocateBlock() to fix , 
* bump pcp 6.9.4

* 2.1.2

* Correct dice example ()

Changed random(6) to random(5) so the number reflect real dice.

* add 4tronix minibit ()

* Update targetconfig.json ()

remove mock-iot-extension as it is just an experimental development by The Foundation

* Update calibrate-compass.md ()

Based on user feedback in Slack https://microbit-community.slack.com/archives/C1ZMKRFHD/p1563274019078400?thread_ts=1563268925.077500&cid=C1ZMKRFHD

* add wukong ()

* Decrease size of GC heap to allow more DAL allocs ()

* 2.1.3

* add Kitronik view text ()

* Release 2.0.6 to live ()

* Update nexus:bit entry  ()

* update nexus:bit entry

* update nexus:bit entry

* Logic Lab mini-course ()

* Logic Lab mini-course

* example syntax

* Updating Readme with branch information.

* bump pxt for ios <=9 fix ()

* Update pxt/common-packages and fix build ()

* fix build off of pxt/ and pxt-common-packages master

* check in generated files

* add-pxt-bmp280 ()

* Bumping pxt-core to 5.19.8 & common-packages to 6.14.9

* 2.1.4

* Error codes page update ()

* Start adding new codes

* few tiny edits

* Add more errors and rearrange

* Update docs/device/error-codes.md

Co-Authored-By: Michał Moskal <michal@moskal.me>

* juggle category

* set error range in hint

Co-Authored-By: Michał Moskal <michal@moskal.me>

* Update docs/device/error-codes.md

Co-Authored-By: Mark <mark@microbit.org>

* fix build ()

* fix broken build

* just try the more 'official' fix if possible

* back to the way that actually works..

* bump pxt to include accessibility changes ()

* 2.1.5

* make hc mode sim color have higher contrast ()

* Show project settings ()

* markdown link fix ()

* add HTS221 ()

* Editor controllers fixes ()

* updated strings

* bump pxt

* anotehr attempt

* 2.1.6

* turn on samples when reading accelerometer ()

* 2.1.7

* hide pin p19/p20 ()

* Fix remove life animation causing microbit stuck ()

On the real microbit board, if the program execute other game blocks while
the remove life animation is playing, it would cause strange behavior or
even make the game stuck.

* Port of Programmable Logic lesson for Logic Lab course ()

* port of programmable logic lesson

* trigger rebuild

* express as logical equation in snippet

* go logical for snippet inputs

* emit enum as bitmask ()

* 2.1.8

* add alt attributes to download screens ()

* add alt attributes to download screens, fixes 

* better descriptions

* fixing links in translate page

* Modify the LED coordinates to be between 0 and 4. ()

Without this change, there is a 11/36 chance no LED lights as [`Math.random(a,b)`](https://docs.python.org/2/library/random.html#random.uniform) (thus the `pick random` block) chooses a number in the (inclusive, closed) interval `[a, b]`.

* Set LED plot row/column ranges for 'Reaction Time' ()

* add LIS2MDL ()

* add LIS2DW12 ()

* add LPS22 ()

* add LSM6DSO ()

* add gator environment ()

* add STTS751 ()

* add inventura extension ()

* add new sparkfun extensions ()

* add new sparkfun extensions

* remove gator environment pending fixes

* add dfplayer mini extension ()

* Update 'servo calibrator' link ()

* I2C Addressing Note ()

* I2C on-board sensor address note

* note for 7bit to 8bit shift

* Add nested summaries for newer courses ()

* bump pxt ()

* bump pxt

* bump

* bump

* fix version

* 2.1.9

* bump package.json ()

* 2.1.10

* bump pxt ()

* 2.1.11

* bump for diff3 ()

* enable experiment

* bump pxt

* 2.1.12

* Add the Stu Lowe coding cards ()

* Add the Stu Lowe coding cards

* Move 'Coding Cards' below 'Hardware'

* Add isDeleted ()

* add xinabox OD01 and breakout display section ()

* add xinabox OD01 and breakout display section

* Update targetconfig.json

* Update extensions.md

* Link to power supply limitations ()

Fixes: 

* Pxt v5.23.17 ()

* bump pxt

* regen docs

* fix version syntax

* restore extension

* removed dup

* 2.1.13

* add-sw01 ()

* Locking old issues

* add Keyestudio robot car ()

* Allow globals in reclaimed bluetooth memory ()

* isTouchingEdge() should not return true for deleted sprite ()

* add query variant to hide toolbar ()

* Adding link to stable refs ()

* Update extensions.md ()

Move the :VIEW Text32 from other to Display now there is a display sections

* 2.1.14

* fixing radio stack ()

* fixing radio stack

* updated shims

* 2.1.15

* Stable points to latest 2.0.9 ()

* Releasing 2.0.9 to live ()

* Fixing signal strength ()

* Pointing to 2.0.10

* Releasing 2.0.10 ()

With radio strength signal fix for hot or cold

* Removing old bitbot as we have a new bitbot package ()

* updated pxt ()

* updated pxt

* bump pxt

* updated react

* updated ptx

* Remove empty variable element from XML

* Bump pxt-core to 5.25.15

* bump pxt

* Bump pxt to 5.25.17

* Add precision to music slider

* 2.1.16

* add drive:bit ()

* micro:bit RSSI fix ()

* read rssi from packet

* updated shims

* fix build

* fix help

* move deprecated function to ts

* some formatting

* restore rssi block

* restory notations

* actually copy bytes

* removing logging code

* simpler wake up code

* comment

* fix build

* bump pxt

* go back to safety

* bump microbit

* restor package.json

* revert jquery v

* use macro

* check length

* bump pxt ()

* 2.1.17

* Use default resize function for microbit gesture dropdown ()

* Name Badge project page ()

* Name Bagde project page

* gotta please the summary check

* link typo, ugh

* Revert "Name Badge project page ()"

This reverts commit 2e2860632b.

* add freenove starter kit ()

* radio.setFrequencyBand support ()

* setfrequencyband support

* revert line change

* add bounds check

* Name Badge project page ()

* Name Bagde project page

* gotta please the summary check

* link typo, ugh

* get rid of the pptx

* Simplify the Fahrenheit from Celsius computation. ()

As the micro:bit introduces floating point arithmetic for both the existing `f = 18 * c / 10 + 32` computation and the new `f = 1.8 * c + 32` computation, there isn't any benefit for the former.

* Enable Polish localization ()

* bump package

* 2.1.18

* shrink maintenance gif

* 2.1.19

* Rotary phone dial ()

* some write up

* adding images

* text

* more text

* adding vids

* adding escape room

* remove newer lesson

* remove .mp4

* Card page edits

* adding image

* adding to toys

* rotary edits

* fix typo

* bump pxt 5.28.7 ()

* bump pxt

* bump to pxt 5.28.8

* 2.1.20

* bump pxt 5.28.9 ()

* 2.1.21

* bump pxt 5.28.10

* 2.1.22

* bump pxt 5.28.11

* 2.1.23

* bump pxt 5.28.12

* 2.1.24

* Update README.md

* robot unicorn ()

* robot unicorn

* Edits to the unicorn

* fix missing radio and boardname

* bump pxt 5.28.18 ()

* bump pxt 5.28.18

* updated summary

* 2.1.25

* bump pxt 5.28.21

* 2.1.26

* bump to pxt5.28.23

* 2.1.27

* Add redirect to pins info to serial heading ()

* Add redirect to pins info to serial heading

* adding links

* vump to pxt 5.28.24

* 2.1.28

* bump to pxt 5.28.26

* 2.1.29

* add build instructions

* updated build notes

* bump pxt 5.28.27

* 2.1.30

* missing svg

* remove crowdin project to disable upload from master branch

* reeanble crowdin, no upload

* 2.1.31

* bump pxt common to 6.16.25

* missing radio package

* Fix GC heap reclamation ()

* bump to pxt 5.28.31

* bump pxt 5.28.32

* 2.1.32

* 2.1.33

* fix typo

* pxt-microbit-next? ()

Since the repo https://github.com/microsoft/pxt-microbit-next doesn't exist, I am assuming that the word `next` is not meant to be here.

* Extensions: Add Inksmith Climate Action Kit ()

* Fixes for typos found in Crowdin - 11252019 ()

* Extension: add Kitronik Halo HD ()

* Extension: Add EBOTICS MIBO ()

* add Bright Wearables Brightboard ()

* Docs: Change default value in Javascript. ()

* Change default value in Javascript.

Per @microbit-mark 's suggestion, add an example of how to change the default interval value by switching to Javascript.

* edits to new example

* bump pxt 5.30.6

* 2.1.34

* update git and vscode settings

* revert changes to 2.1.28

* package-lock

* v2.1.34

* Change Hero Image

* add RVR ()

* Extension: add minicruise ()

* Fix minutes display for 'Digital Watch' project ()

* Fix minutes display for 'Digital Watch' project

* minutes less than 10

* bump pxt

* 2.1.35

* updated pxt

* 2.1.36

* package lock

* Tutorial Typo Fix

* staging Servo library support

* bumppxt

* 2.1.37

* update error guide link ()

* adding radio firefly ()

* Update 'Metal Detector' example ()

* bump pxt

* 2.1.38

* typoFix

* package lock

* Update Pins

* Update Pins

* Add C7, C8 and C9 Serial Pins

* Add C7, C8 and C9 Serial Pins

* Pins update

* Add maqueen ()

* Extensions: Add DFRobot Maqueen

* fix

* revert pin C7, C8 and C9

* Update README.md

* add extension doc file

* revert pxt bump

* Docs: Extensions remove headliner

* Remove outdated #ifdef ()

* Extensions: add servobit ()

Co-authored-by: Abhijith Chatra <abchatra@microsoft.com>

* bump to pxt 5.31.8, common 6.18.2

* 2.1.39

* enable github editor experiment ()

* Fix missing sim function

* bump to pxt 5.31.10

* 2.1.40

* Modify snippets/examples relying of fp div ()

* Extensions: add DFRobot natural science board ()

* Extensions: add Kitronik clip dtector ()

Co-authored-by: Abhijith Chatra <abchatra@microsoft.com>

* missing image

* Fix lesson images

* fix images 2

* Add SpeedPicker to Motor Blocks

* add sixth motor pin (M_GND3)

Co-authored-by: Abhijith Chatra <abchatra@microsoft.com>
Co-authored-by: Peli de Halleux <pelikhan@users.noreply.github.com>
Co-authored-by: Galen Nickel <v-gani@microsoft.com>
Co-authored-by: Joey Wunderlich <jwunderl@users.noreply.github.com>
Co-authored-by: Danny Yates <danny@codeaholics.org>
Co-authored-by: Sam Kent <32453267+microbit-sam@users.noreply.github.com>
Co-authored-by: Michał Moskal <michal@moskal.me>
Co-authored-by: Daryl Zuniga <Daryl.Zuniga@gmail.com>
Co-authored-by: Eric Kimsey <ekimsey@users.noreply.github.com>
Co-authored-by: Mark <mark@microbit.org>
Co-authored-by: Richard Knoll <riknoll@users.noreply.github.com>
Co-authored-by: Peter Brodersen <peter@ter.dk>
Co-authored-by: Leo <leo881003@gmail.com>
Co-authored-by: Asher Kach <asher.kach@gmail.com>
Co-authored-by: Franklin Tse <FranklinWhale@users.noreply.github.com>
Co-authored-by: Neal McBurnett <nealmcb@gmail.com>
Co-authored-by: Kitronik Ltd  <design@kitronik.co.uk>
Co-authored-by: shakao <34112083+shakao@users.noreply.github.com>
Co-authored-by: Helen Leigh <48659173+helenleigh@users.noreply.github.com>
Co-authored-by: Gerard Braad <me@gbraad.nl>
Co-authored-by: Nicole Parrot <cleoqc1124@gmail.com>
2020-01-21 10:38:36 -08:00

82 lines
1.9 KiB
Markdown

# Smiley Buttons
## Introduction @unplugged
Code the buttons on the @boardname@ to show that it's happy or sad.
(Want to learn how the buttons works? [Watch this video](https://youtu.be/t_Qujjd_38o)).
![Pressing the A and B buttons](/calliope/tutorials/03_smiley_button_animation.gif)
## Step 1 @fullscreen
Place a ``||input:on button pressed||`` block to run code when button **A** is pressed.
```blocks
input.onButtonPressed(Button.A, () => {
});
```
## Step 2 @fullscreen
Place a ``||basic:show leds||`` block inside ``||input:on button pressed||`` to display a smiley on the screen. Press the **A** button in the simulator to see the smiley.
```blocks
input.onButtonPressed(Button.A, () => {
basic.showLeds(`
# # . # #
# # . # #
. . . . .
# . . . #
. # # # .`
);
});
```
## Step 3 @fullscreen
Add ``||input:on button pressed||`` and ``||basic:show leds||`` blocks to display a frowny when button **B** is pressed.
```blocks
input.onButtonPressed(Button.B, () => {
basic.showLeds(`
# # . # #
# # . # #
. . . . .
. # # # .
# . . . #`
);
});
```
## Step 4 @fullscreen
Add a secret mode that happens when **A** and **B** are pressed together. For this case, add multiple ``||basic:show leds||`` blocks to create an animation.
```blocks
input.onButtonPressed(Button.AB, () => {
basic.showLeds(`
. . . . .
# . # . .
. . . . .
# . . . #
. # # # .
`)
basic.showLeds(`
. . . . .
. . # . #
. . . . .
# . . . #
. # # # .
`)
})
```
## Step 5
If you have a @boardname@, connect it to USB and click ``|Download|`` to transfer your code. Press button **A** on your @boardname@. Try button **B** and then **A** and **B** together.
## Step 6
Nice! Now go and show it off to your friends!