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

53 lines
1.2 KiB
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# Show Number
2016-04-13 17:27:45 +02:00
Show a number on the [LED screen](/device/screen), one digit at a time (scrolling from left to right)
2016-03-26 00:47:20 +01:00
~~~~sig
basic.showNumber(2, 150)
~~~~
### Parameters
2016-04-13 17:27:45 +02:00
* value - a [Number](/reference/types/number)
* (optional) interval (ms) - [Number](/reference/types/number); the time (in milliseconds) before scrolling by one LED; the larger the number, the slower the scroll
2016-03-26 00:47:20 +01:00
### ~
To display the number 10:
~~~~blocks
basic.showNumber(10)
~~~~
To display the number stored in the `x` variable:
~~~~blocks
let x = 1
basic.showNumber(x)
~~~~
### Example: count to 5
2016-04-13 17:27:45 +02:00
This example uses a [for](/reference/loops/for) loop to show numbers ``1`` through ``5`` on the screen:
2016-03-26 00:47:20 +01:00
~~~~blocks
for (let i = 0; i < 5; i++) {
basic.showNumber(i + 1)
basic.pause(200)
}
~~~~
### Other show functions
2016-04-13 17:27:45 +02:00
* use [show string](/reference/basic/show-string) to show a string on the screen
* use [show animation](/reference/basic/show-animation) to show a series of images on the screen
2016-03-26 00:47:20 +01:00
### Lessons
2016-04-13 17:27:45 +02:00
* [lucky 7](/lessons/lucky-7)
2016-03-26 00:47:20 +01:00
### See also
2016-04-13 17:27:45 +02:00
[show string](/reference/basic/show-string), [show animation](/reference/basic/show-animation), [Number](/reference/types/number), [math library](/js/math)
2016-03-26 00:47:20 +01:00