pxt-calliope/docs/reference/led/toggle.md
Sam El-Husseini e3975e65e5 pxt-microbit Accessibility PR (#529)
* Accessibility changes
2017-09-07 13:42:08 -07:00

919 B

Toggle

Toggle a LED light on the LED screen, meaning to turn it on (off) if it is off (on). Specify which LED using x, y coordinates.

led.toggle(0,0)

Parameters

  • x - Number; the x coordinate or horizontal position (0, 1, 2, 3, 4)
  • y - Number; the y coordinate or vertical position (0, 1, 2, 3, 4)

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

x, y coordinates?

The LED screen is made up of 25 LEDs arranged in a 5x5 grid. To figure out the x, y coordinates, see LED screen.

Example

This code toggles the centre LED:

led.toggle(2, 2)

See also

toggle all, plot, unplot, point, LED screen,