 
 
 //--------------------------------------------------// The following values are for the "Shimmer" routine
-int pixelvalue[7];                                  // array to store the address location of each pixel event, 8 in total
-int countval[7];                                    // array to store the counter for each pixel event, 8 in total
-int pixelgo[7];                                     // array to store the activation bit for each pixel event, 8 in total
-int pixmax = 512;                                   // int to store the max brightness for each pixel event
-int pixelcol[7];                                    // array to store the colour decision
-int pixcoldic[7];                                   // array to store the colour decision bit
-int pixmat[7];                                      // array to indicate whether a pixel is stepping on another pixel
+int pixelvalue[8];                                  // array to store the address location of each pixel event, 8 in total
+int pixelgo[8];                                     // array to store the activation bit for each pixel event, 8 in total
+int pixmax = 512;                                   // int to store the max animation keyframe for each pixel event
+int pixelcol[8];                                    // array to store the colour decision
+int pixcoldic[8];                                   // array to store the colour decision bit
+int pixmat[8];                                      // array to indicate whether a pixel is stepping on another pixel
 int delayval;                                       // integer to hold delay value
 int randosparkle =0;                                // integer to hold the random number value
-int randosparklenum[] = {1,2,3,4,5,6,7,8};          // integer to hold the magic numbers governing which pixel fires next
+int randosparklenum[] = {1,30,54,43,2,100,150,97};  // integer to hold the magic numbers governing which pixel fires next
 int maxbright;                                      // integer to determine max bright
+long oldPosition  = 255;                            // integer to store encoder value
+int pixupdn[8];                                     // array to store the pixel ascent/descent for each possible pixel
+int pixbrt[8];                                      // array to store the pixel brightness for each possible pixel
+int pixpos;                                         // array to store the pixel brightness for each possible pixel
+int firstrun = 0;                                   //array to write first run values to pixels
+int shimspd[8];                                    //array to set random speed value for shimmer
 
 void setup() {                                      //-----------------------------------------------(Setup)
     pinMode(butpin, INPUT);                         // Set buttonpin as input
     Serial.begin(9600);                             // Initialize Serial Debug
     pixels.begin();                                 // This initializes the NeoPixel library.
+
+
+
 }
 
 void loop() {                                       //-----------------------------------------------(Main Loop)
-    pixels.setBrightness(255);
-    
-    butcheck();
-
-    if (butsel == 1){
-        clearscreen();
-        colourfade();
-    }
-
-if (butsel == 2){
-        clearscreen();
-        shimmer();
-    }
-    
-    Serial.println(butsel);
-    pixels.show();                                  // This sends the updated pixel color to the hardware.
-    delay(40);
+
+  if (firstrun == 0){
+    for (int i=0; i <= 7; i++){                      //For loop to write initial random position
+        pixelvalue[i] = random(LOWPIXELS,NUMPIXELS);
+        firstrun = 1;
+        }
+    
+  }
+  butcheck();
+
+  if (butsel == 1){
+      clearscreen();
+      colourfade();
+  }
+  
+  if (butsel == 2){
+      clearscreen();
+      shimmer();
+  }
+  
+  //Serial.println(pixupdn[1]);
+  pixels.show();                                  // This sends the updated pixel color to the hardware.
+
+  
+  
+
+  delay(40);
   
 }
 

    }
    
    
    potVal = analogRead(potPin);                    //determine delay
    potVal = map(potVal, 0, 1024, 0, 500);
    
    
    for(int i=LOWPIXELS;i<NUMPIXELS;i++){
        pixels.setPixelColor(i, pixels.Color(rval,gval,bval));

}

void colourfade(){                                  //-----------------------------------------------(Colour Fade Function)

    long newPosition = myEnc.read();
    if (newPosition != oldPosition) {
        oldPosition = newPosition;
        Serial.println(newPosition);
    }
    if (newPosition > 255){
      myEnc.write(1);
    }
    if (newPosition < 1){
      myEnc.write(255);
    }
    
    magicnumber = random(0,30);                     //creates a magic number

