colorLeds[i].intensity()

Category:Circuit Playground

Changes the brightness of the color LED

With colorLeds[i].intensity(), you can control how bright or dim you want a colorLED to be with a number. The bigger the number used, the brighter the color LED.

.intensity() works a lot like buzzer.frequency and is just rapidly turning the light on and off, giving the illusion of dimness.

Examples

Example: Light Dimmer

onEvent("intensity_slider", "input", function(event) {
  // Change the brightness of the color LEDs
  colorLeds[0].intensity(getNumber("intensity_slider"));
});

Syntax

colorLeds[index].intensity(brightness)

Parameters

Name Type Required? Description
brightness number A number between 0-100 that controls how bright the LED will appear.

Tips

  • A common usage of colorLeds[i].intensity() is with a slider or some sort of variable that you can easily change or update.

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