// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// Released under the GPLv3 license to match the rest of the
// Adafruit NeoPixel library

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

// Which pin on the Arduino is connected to the NeoPixels?
#define PIN        2 // On Trinket or Gemma, suggest changing this to 1

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 32 // Popular NeoPixel ring size
#define BLOCKLENGTH 5
//#define DEBUG 0

// When setting up the NeoPixel library, we tell it how many pixels,
// and which pin to use to send signals. Note that for older NeoPixel
// strips you might need to change the third parameter -- see the
// strandtest example for more information on possible values.
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

#define DELAYVAL 150 // Time (in milliseconds) to pause between pixels


#ifdef DEBUG
#define DEBUGMSG(m) Serial.println(m)
#else
#define DEBUGMSG(m)
#endif


void setup() {
  // These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
  // Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  clock_prescale_set(clock_div_1);
#endif
  // END of Trinket-specific code.

  Serial.begin(9600);

  pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
}


void loop() {
  pixels.clear(); // Set all pixel colors to 'off'
  selectpixel();
  DEBUGMSG("Loop");
//  delay(200);
}

void selectpixel(){
int ACTIVEPIXEL = 0;
for(int i=0; i<BLOCKLENGTH; i++) { // For each pixel...
  writeall(ACTIVEPIXEL);
  ACTIVEPIXEL++;
  DEBUGMSG("Select pixel");
  }
//  delay(DELAYVAL);
}

void writeall(int ACTIVEPIXEL){
  int ACTIVEBLOCK = 0;
  int BLOCKSTART = 0;
  int BLOCKCOUNT = (NUMPIXELS/BLOCKLENGTH);
for(int i=0; i<BLOCKCOUNT+1; i++) { // For each pixel...
  BLOCKSTART = ACTIVEBLOCK * BLOCKLENGTH;   
  writeblock(ACTIVEPIXEL, BLOCKSTART);
  ACTIVEBLOCK++;
  }
  delay(DELAYVAL);
  //delay(2000);
}

void writeblock(int ACTIVEPIXEL, int BLOCKSTART) {
  for(int i=0; i<BLOCKLENGTH; i++) { // For each pixel...
    pixels.setPixelColor(BLOCKSTART+i, pixels.Color(0, 0, 0));
}
DEBUGMSG(BLOCKSTART+ACTIVEPIXEL);
pixels.setPixelColor(BLOCKSTART+ACTIVEPIXEL, pixels.Color(254, 254, 254));
pixels.show();   // Send the updated pixel colors to the hardware.  }
}

uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
ring1:GND
ring1:VCC
ring1:DIN
ring1:DOUT
ring2:GND
ring2:VCC
ring2:DIN
ring2:DOUT