Skip to content

SetFadeRate()

Arnd edited this page Dec 11, 2020 · 3 revisions

SetFadeRate(FadeSpeed);

This function will turn the fader off or on at a certain speed. The library makes use of 2 triggers on the Arduino TIMER0, which is used by the millis() timing function and is set to trigger approximately every millisecond. Using a FadeSpeed of 1 means that each colored LED will fade 2 units per millisecond. Since range of full brightness to off is 255, using a value of 1 means that a light will fade in .128 seconds, a setting of 4 equates to a full fade in just over a half-second. The system defaults to a fade rate of 2. If the fade mode is turned off, the LEDs will remain at their defined intensity levels until explicitly changed via a SetColor() or SetLEDState() command.


Example:

// Instantiate the class using all of the pins defined in constants     //
EncoderClass Encoder(ROTARY_PIN_1, ROTARY_PIN_2, PUSHBUTTON_PIN, RED_PIN, 
                     GREEN_PIN, BLUE_PIN);

void setup() {
  Serial.begin(115200);
  delay(1000);
  Encoder.SetFade(0);     // turn off fade mode
  delay(10000);           // wait for 10 seconds to let someone fiddle with the controls
  Encoder.SetFadeRate(3); // turn on the fader to fade in .382 seconds
} // of method setup()
void loop(){
  // code goes here //
} // of method loop()