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

A Stroboscope

As seen in the SpinWheel stroboscope adventure

#include "SpinWearables.h"
using namespace SpinWearables;

First we would like to ensure the brightness is set to maximum, as we are not going to use the LEDs for aesthetics, but rather as a source of illumination.

void setup() {

We will set the default period to 10 milliseconds and let it vary from 8 milliseconds to 12 milliseconds.

long default_delay_time = 10000;
long max_correction = 2000;

And now we have the main body of the program, which will turn the light on and then off rapidly.

void loop() {

We first read the tilt of the device and use it to modify the default period.

  long delaytime = default_delay_time + * max_correction;

Set the lights on.

  SpinWheel.setLargeLEDsUniform(255, 255, 255);

Wait only a small fraction of the total period (3% in this case).


Then turn the lights off and wait for the rest of the time.

  SpinWheel.setLargeLEDsUniform(0, 0, 0);

Notice we used drawLargeLEDFrame() instead of drawFrame(). We did so because drawFrame also sets the small LEDs, which used a much slower persistence-of-vision pattern and can not work at more than 50 frames per second.