#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif

// Pin connected to the NeoPixels
#define PIN            6

//NeoPixels attached to the Arduino
#define NUMPIXELS      16

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int delayval = 20; // delay for half a second
int color;

void setup() {
  pixels.begin(); // This initializes the NeoPixel library.
}

void loop() {
  colorWheel(70);

}
void colorWheel(uint8_t wait) {
  int i, j;

  for (j = 0; j < 256; j=j+3) {
    for (i = 0; i < pixels.numPixels(); i++) {
      pixels.setPixelColor(i, Wheel((i*4+j) & 255));
      delay(wait);
      pixels.show();
    }
    
    for (i = 1; i < pixels.numPixels(); i++) {
      pixels.setPixelColor(i, 0,0,0);
      delay(wait/3);
      pixels.show();
    }
  }
  j=0;

}
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if (WheelPos < 85) {
    return pixels.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if (WheelPos < 170) {
    WheelPos -= 85;
    return pixels.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return pixels.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}