5f7a8e5301
* update yotta defaults for 16kb devices * refactor deprecated blocks * updates for button events * update button events * update refference * update docs * update docs * update button event blocks * update docs * update block id
53 lines
1.3 KiB
Markdown
53 lines
1.3 KiB
Markdown
# Show Number
|
|
|
|
Show a number on the [LED screen](/device/screen). It will slide left if it has more than one digit.
|
|
|
|
```sig
|
|
basic.showNumber(2)
|
|
```
|
|
|
|
## Parameters
|
|
|
|
* `value` is a [Number](/types/number). If the number is not single-digit number, it will scroll on the display.
|
|
* `interval` is an optional [Number](/types/number). It means the number of milliseconds before sliding the `value` left by one LED each time. Bigger intervals make the sliding slower.
|
|
|
|
## Examples:
|
|
|
|
To show the number 10:
|
|
|
|
```blocks
|
|
basic.showNumber(10)
|
|
```
|
|
|
|
To show the number stored in a variable:
|
|
|
|
```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:
|
|
|
|
```blocks
|
|
for (let i = 0; i < 6; i++) {
|
|
basic.showNumber(i)
|
|
basic.pause(200)
|
|
}
|
|
```
|
|
|
|
## Advanced
|
|
|
|
If `value` is `NaN` (not a number), `?` is displayed.
|
|
|
|
## Other show functions
|
|
|
|
* Use [show string](/reference/basic/show-string) to show a [String](/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.
|
|
|
|
## See also
|
|
|
|
[show string](/reference/basic/show-string), [show animation](/reference/basic/show-animation), [Number](/types/number), [math](/blocks/math)
|
|
|