Skip to content
Arnd edited this page Jan 17, 2021 · 3 revisions

set( {value} [, {speed}] );

The set() function is called to set the PWM value of a pin. The PWM value is an integer between 0 ("OFF") and 1023 (100% "ON"). If the second parameter is omitted the pin is set to the PWM value immediately, if the second parameter is specified then the LED will fade/brighten from the current setting to the new setting at the speed specified. A speed of 1 is the slowest and a speed of 255 is the fastest. The length of time it takes from OFF to ON at a speed of 255 is about half a second - the fastest rate possible.

The set() function returns immediately while any fading/brightening happens in the background


Example:

...    
...    
smoothLED Board;
...    
...    
Serial.print(F("BOARD LED: "));
if (Board.begin(LED_BUILTIN)) // Start the "Board" instance on pin 13
  Serial.println(F("OK"));
else
  Serial.println(F("ERROR!"));
Board.set(0); // set to OFF
Board.set(1023,1); // Slowly brighten the LED
...    
...    
Clone this wiki locally