pxt-calliope/docs/reference/led/plot.md

69 lines
1.4 KiB
Markdown
Raw Permalink Normal View History

2016-03-26 00:47:20 +01:00
# Plot
2016-06-13 21:57:42 +02:00
Turn on the LED light you say on the [LED screen](/device/screen).
2016-03-26 00:47:20 +01:00
```sig
led.plot(0,0);
```
2016-06-13 21:57:42 +02:00
## ~hint
Use [unplot](/reference/led/unplot) to turn **off** an LED.
## ~
2016-03-26 00:47:20 +01:00
### Parameters
2016-07-18 20:14:51 +02:00
* ``x`` is a [number](/reference/types/number) that means the
horizontal spot on the LED screen (from left to right: 0, 1, 2, 3,
or 4)
* ``y`` is a [number](/reference/types/number) that means the vertical
spot on the LED screen (from top to bottom: 0, 1, 2, 3, or 4)
2016-06-13 21:57:42 +02:00
If a parameter is [out of bounds](/reference/out-of-bounds) (a value
other than 0 to 4), then this function will do nothing.
### ~hint
2016-03-26 00:47:20 +01:00
2016-06-13 21:57:42 +02:00
The LED screen is a solid square of LEDs with five LEDs on each side.
To learn more about how you number the LEDs with ``x`` and ``y``
coordinates, see [LED screen](/device/screen).
2016-03-26 00:47:20 +01:00
2016-06-13 21:57:42 +02:00
### ~
2016-03-26 00:47:20 +01:00
2016-06-13 21:57:42 +02:00
### Example: One LED
2016-03-26 00:47:20 +01:00
2016-06-13 21:57:42 +02:00
This program turns on the bottom right LED.
2016-03-26 00:47:20 +01:00
```blocks
2016-06-13 21:57:42 +02:00
led.plot(4, 4)
2016-03-26 00:47:20 +01:00
```
2016-06-13 21:57:42 +02:00
### Example: Square
2016-03-26 00:47:20 +01:00
This program uses a [for loop](/blocks/loops/for)
2016-06-13 21:57:42 +02:00
and the `plot` function
to make a square around the edges of the LED screen.
2016-03-26 00:47:20 +01:00
```blocks
for (let i = 0; i < 5; i++) {
led.plot(0, i)
led.plot(4, i)
led.plot(i, 0)
led.plot(i, 4)
basic.pause(500)
}
```
2016-06-13 21:57:42 +02:00
### ~hint
Use the [point](/reference/led/point) function to find out if an LED is
on or off.
### ~
2016-03-26 00:47:20 +01:00
### See also
2016-04-13 17:27:45 +02:00
[unplot](/reference/led/unplot), [point](/reference/led/point), [LED screen](/device/screen)