pxt-calliope/docs/reference/led/plot.md
2016-06-14 17:20:45 -04:00

1.4 KiB

Plot

Turn on the LED light you say on the LED screen.

led.plot(0,0);

~hint

Use unplot to turn off an LED.

~

Parameters

  • x is a number that means the horizontal spot on the LED screen (from left to right: 0, 1, 2, 3, or 4)
  • y is a number that means the vertical spot on the LED screen (from top to bottom: 0, 1, 2, 3, or 4)

If a parameter is out of bounds (a value other than 0 to 4), then this function will do nothing.

~hint

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.

~

Example: One LED

This program turns on the bottom right LED.

led.plot(4, 4)

Example: Square

This program uses a for loop and the plot function to make a square around the edges of the LED screen.

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)
}

~hint

Use the point function to find out if an LED is on or off.

~

See also

unplot, point, LED screen