Adafruit NeoPixel Ring as LED “mood” light

Recently I picked up a couple of Adafruit NeoPixel Ring boards – didn’t have anything particular in mind for them but they’re LEDs and you just can’t have enough LEDs πŸ™‚

The first impression is of the overwhelming build quality – they are a seriously nicely made piece of kit. The next thing that hits you is how easy they are to use – the simplicity and quality of the Adafruit NeoPixel library is outstanding. I do find simple LED colour changing objects to be relaxing so I was looking at an empty white plastic vitamin pot and thinking “hmmmmmmmm………”

The NeoPixel ring only needs one pin to push out RGB data to the LED pixels. That got me thinking of ATtiny85. When I started playing around with the Adafruit example “strandtest” I couldn’t help spot that the compiled sketch was only about 2.5K. Obviously, that means an ATtiny45 would do. Both of the tiny chips can be picked up for less than 60p if you’re willing to buy a sensible number (such as a “tube” of 25). Otherwise you’re paying 3-4 times that per chip – it’s a no-brainer really.

My first thoughts were to use a small piece of veroboard:

Second attempt with veroboard

Second attempt with veroboard

That’s my second attempt. I had a soldering fail on the first one (nothing unusual there, that’s partly why I hate veroboard). I perservered, and cocked this one up too πŸ™

Right, time for adafruit perma-proto…

Proper job!

Proper job!

That was better. I decided to use a micro-USB breakout and short male micro-USB to femaie USB-“A” cable just to make connecting this easier. After losing 2 x Attiny45’s (couldn’t be bothered de-soldering them from the veroboard – can you see why I buy in bulk? :)) I initially cocked this up and forgot to set the fuses for 8MHz internal clock. That’s why I added the extra pins which allow the tiny45 to be programmed in-situ.

You can see that I’ve snipped the corners off the perma-proto board. Here’s why:

It fits!

It fits!

I’m going to hot glue that to stop it working loose but it’s a pretty tight fit as things stand. All that’s left is to put the pot on top and test it…

All gone to pot...

All gone to pot…



The colours are set to change fairly slowly. Here’s the code:

#include <Adafruit_NeoPixel.h>

#define PIN 3

// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(16, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  strip.begin();; // Initialize all pixels to 'off'

void loop() {
  // Some example procedures showing how to display to the pixels:
  colorFill(strip.Color(255, 0, 0), 1000); // Red
  colorFill(strip.Color(0, 255, 0), 1000); // Green
  colorFill(strip.Color(0, 0, 255), 1000); // Blue
  colorFill(strip.Color(0x80, 0, 0x40), 1000); // Perpl

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, c);

// Fill the dots with the same color
void colorFill(uint32_t c, int wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, c);

void rainbow(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256; j++) {
    for(i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel((i+j) & 255));

// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
    for(i=0; i< strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  if(WheelPos < 85) {
   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  } else if(WheelPos < 170) {
   WheelPos -= 85;
   return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else {
   WheelPos -= 170;
   return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);

There’s a lot of stuff in there that isn’t necessary – I just hacked at it to make it work. This is what I have uploaded though so I don’t want to faff with it unless I upload it again.

And, guess what? Yup…

As usual, the colours are way better in real life. I’m too tight to buy a decent camera though πŸ™‚

This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to Adafruit NeoPixel Ring as LED “mood” light

  1. Ben says:

    Hi, I get some errors from your source because it containts incorrect characters. Can you be so kind and solve that ? For example the include at the start omits the and there are some &lt signs every now and then in the source.



  2. Dave Boulton says:

    Hi Ben,

    Sure that should be easy to fix – I’ve found a better way of including code since I wrote this.


Leave a Reply

Your email address will not be published. Required fields are marked *