Arduino_APA102 - setBrightness()

Set the brightness of the LEDs, this scales the values that have been set by setPixelColor() and scale them by the percentage used in the parameter.

Syntax

led.setBrightness(50)

Parameters

  • (optional) IndexLed: Choose one LED to change its value
  • newBrightness: Percentage amount to scale the color’s values of the LEDs (0% - 100%)

Example

#include <Arduino_APA102.h> 

Arduino_APA102 leds(5, 5, 4);

void setup() {
  leds.begin();

  leds.setPixelColor(0, 0xFFFFFF);
  leds.setPixelColor(1, 0xFFFFFF);
  leds.show();
  delay(1000);
} 

void loop() {
  leds.setBrightness(50); //Set global brightness
  leds.show();
  delay(1000);

  leds.setBrightness(0, 10);  //Change LED 0 's brightness
  leds.show();
  delay(1000);
} 

See also