The code presented on this page can be downloaded or found in the Arduino examples menu under Examples → SpinWearables → Animations_and_Patterns → Smoother_Blink.


#include "SpinWearables.h"
using namespace SpinWearables;

void setup() {
  SpinWheel.begin();
}

void loop() {
  int t = millis();
  int t_repeating = t % 2500;

The triangularWave function has a period of 256 and provides for a smooth ramp-up and ramp-down.

  int b = triangularWave(t_repeating / 10);

The next function takes three arguments: The red, green, and blue components of the color we desire. We are mixing only red and blue, setting green to zero.

  SpinWheel.setLargeLEDsUniform(b, 0, b);
  SpinWheel.drawFrame();
}