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

48 lines
1.2 KiB
Markdown
Raw Permalink Normal View History

2016-03-26 00:47:20 +01:00
# Point
2016-06-14 00:47:08 +02:00
Find whether the LED you say on the
[LED screen](/device/screen) is on or off.
2016-03-26 00:47:20 +01:00
```sig
led.point(0,0);
```
### 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-03-26 00:47:20 +01:00
2016-06-14 00:47:08 +02:00
If a parameter is [out of bounds](/reference/out-of-bounds) (a value
other than 0 to 4), this function will return `false`.
2016-03-26 00:47:20 +01:00
### Returns
2016-06-15 13:55:19 +02:00
* a [boolean](/blocks/logic/boolean). If it is `true`, that means the LED is on. If it is `false`, that means the LED is off.
2016-03-26 00:47:20 +01:00
2016-06-14 00:47:08 +02:00
### ~hint
2016-03-26 00:47:20 +01:00
2016-06-14 00:47:08 +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-14 00:47:08 +02:00
### ~
2016-03-26 00:47:20 +01:00
2016-06-14 00:47:08 +02:00
### Example: Toggle off
This program turns the center LED (2, 2) off if it is already on. (If
it is already off, this program leaves it off.)
2016-03-26 00:47:20 +01:00
```blocks
2016-06-14 00:47:08 +02:00
if (led.point(2, 2)) {
led.unplot(2, 2)
2016-03-26 00:47:20 +01:00
}
```
### See also
2016-06-14 00:47:08 +02:00
[unplot](/reference/led/unplot), [plot](/reference/led/plot), [LED screen](/device/screen)
2016-03-26 00:47:20 +01:00