Datasheet

Advanced Coding
Help! My Arduino servo code stops working when combined with NeoPixels!
Unfortunately the NeoPixel and Servo libraries don’t play nice together; one is dependent on
periodically disabling interrupts, the other absolutely requires interrupts. There are a couple of
options here:
Use a dedicated servo control shield (http://adafru.it/1411) or breakout
board (http://adafru.it/815), offloading that task from the processor so interrupts are a non-
issue.
Use a hardware-PWM-based servo library (http://adafru.it/eda) rather than the stock
Arduino Servo library. This can provide rock-steady servo timing without interrupts, but can
only control a very limited number of servos (2-3), and only on very specific pins.
How fast can I refresh a string of (N) pixels?
NeoPixels receive data from a fixed-frequency 800 KHz datastream (except forV1” Flora pixels,
which use 400 KHz). One bit therefore requires 1/800,000 sec — 1.25 microseconds. One pixel
requires 24 bits (8 bits each for red, green blue) — 30 microseconds. After the last pixel’s worth
of data is issued, the stream must stop for at least 50 microseconds for the new colors to “latch.”
For a strip of 100 pixels, that’s (100 * 30) + 50, or 3,050 microseconds. 1,000,000 / 3,050 = 328
updates per second, approximately.
However
That’s only the time needed to push the bits down the wire. The actual refresh rate will be
something less than this, and can’t be estimated as a single number for all cases. It takes time to
process each “frame of animation. How much time depends on the complexity of the math and
the efficiency of the code (for example, floating-point calculations can be relatively slow). The
technique above gives a maximum theoretical rate, but that’s just a starting point. Reality in
some cases could fall an order of magnitude (or more) below this.
For exploratory benchmarking, you can always write code as if a large number of pixels were
present, and time the result. The extra output bits will simply be ignored by the strip (or you can
even test with no NeoPixels connected at all).
That won’t do. Now what?
Because NeoPixels use a fixed-frequency clock, options are limited. You can’t switch out for a
faster microcontroller and expect substantially different results.
One option is to use a different LED type, such as our LPD8806 strips or WS2801 pixels. These
can be driven at higher data rates, though they do have some other tradeoffs with respect to
NeoPixels (cost, color resolution and/or pixel density).
© Adafruit Industries https://learn.adafruit.com/adafruit-neopixel-uberguide Page 36 of 39