pxt-calliope/docs/reference/basic/show-number.md

49 lines
1.2 KiB
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# Show Number
Show a number on the [LED screen](/device/screen). It will slide left if it has more than one digit.
2016-03-26 00:47:20 +01:00
~~~~sig
basic.showNumber(2, 150)
~~~~
### Parameters
* `value` is a [Number](/reference/types/number).
* `interval` is an optional [Number](/reference/types/number). It means the number of milliseconds before sliding the `value` left by one LED each time. Bigger intervals make the sliding slower.
2016-03-26 00:47:20 +01:00
### Examples:
2016-03-26 00:47:20 +01:00
To show the number 10:
2016-03-26 00:47:20 +01:00
~~~~blocks
basic.showNumber(10)
~~~~
To show the number stored in a variable:
2016-03-26 00:47:20 +01:00
~~~~blocks
let x = 1
basic.showNumber(x)
~~~~
### Example: count to 5
This example uses a [for](/blocks/loops/for) loop to show numbers ``0`` through ``5`` on the screen:
2016-03-26 00:47:20 +01:00
~~~~blocks
for (let i = 0; i < 6; i++) {
basic.showNumber(i)
2016-03-26 00:47:20 +01:00
basic.pause(200)
}
~~~~
### Other show functions
* Use [show string](/reference/basic/show-string) to show a [String](/reference/types/string) with letters on the screen.
* Use [show animation](/reference/basic/show-animation) to show a group of pictures on the screen, one after another.
2016-03-26 00:47:20 +01:00
### See also
[show string](/reference/basic/show-string), [show animation](/reference/basic/show-animation), [Number](/reference/types/number), [math](/blocks/math)
2016-03-26 00:47:20 +01:00