colorLeds[i].on()

Category:Circuit Playground

Turns the specified colorLED on.

This method works just like led.on() and will keep whichever LED is specified on. You can turn the colorLED off with colorLeds[i].off().

By default, colorLeds[i].on() turns on all three parts of the LED (red, green, and blue) to produce white. Use colorLeds[i].color() to change the color. colorLeds[i].color() does not need to be used with the on method, it automatically turns the LED(s) on.

Examples

onBoardEvent(buttonL, "down", function(event) {
  colorLeds[0].on();
  colorLeds[9].on();
});
onBoardEvent(buttonR, "down", function(event) {
  colorLeds[0].off();
  colorLeds[9].off();
});

Syntax

colorLeds[index].on()

Found a bug in the documentation? Let us know at documentation@code.org