Neopixel colour changer - stops working.

I'm having trouble implementing a simple colour changer using 4 Neopixel 1/4 ring and Nano. It seems to work through the first 2 colours but then, what looks like a power drop, the current colour remains permanent albeit dimmed. Im also having issues with my cct but I've run the Strand Test example from Adaruit and everything seems fine. My cct issue is that I can't upload when I have the Neopixel ring attached.

Any help with my code will be appreciated.

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

Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);

const byte numReadings = 15;
const byte sensitivity = 52;
const int fadeTime = 500;
const int waitTime = 2000;
const int pixels = strip.numPixels();
const byte ARRAY_SIZE = 13;

const byte colours[] = {140, 5, 9,
                        195, 69, 0,
                        171, 126, 0,
                        255, 216, 1,
                        4, 92, 18,
                        0, 147, 174,
                        23, 114, 205,
                        7, 40, 155,
                        30, 38, 113,
                        16, 20, 83,
                        96, 18, 102,
                        127, 0, 22,
                        255, 148, 131,
                        255, 255, 255
                       };

byte colR = 0;
byte colG = 0;
byte colB = 0;

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

void loop() {
  delay(waitTime);
  colourCycle();
}

void colourCycle() {
  for (int j = 0; j < sizeof(colours); j = j + 3) {
    
    //show colour
    for (int k = 0; k < fadeTime; k++) {
      uint32_t col = getColour(k, fadeTime, colR, colG, colB, colours[j], colours[j+1], colours[j+2]);
      for (int i = 0; i < pixels; i++) {
        strip.setPixelColor(i, col);
      }
      strip.show();
    }

    if (j < ARRAY_SIZE - 3) {
      colR = colours[j];
      colG = colours[j + 1];
      colB = colours[j + 2];
    } else {
      colR = colours[0];
      colG = colours[1];
      colB = colours[2];
    }
    
    delay(waitTime);
  }
}

uint32_t getColour(int i, int f, byte cR, byte cG, byte cB, byte cRN, byte cGN, byte cBN) {
  
  byte r = 0;
  byte g = 0;
  byte b = 0;

  float rL = cRN - cR;
  float gL = cGN - cG;
  float bL = cBN - cB;

  r = byte(cR + rL / f * i);
  g = byte(cG + gL / f * i);
  b = byte(cB + bL / f * i);
  
//  Serial.print(r);
//  Serial.print(" ");
//  Serial.print(g);
//  Serial.print(" ");
//  Serial.println(b);

  return strip.Color(r, g, b);
}

If the big black rectangle is the Arduino, it cannot power very many NeoPixels.
Use an external 5 volt power supply for the strip with its GND connected to both the Arduino and the strip.

.

Thanks LarryD.

It seems that the Strand Test uses less power than my static example but my cct is wrong and needs fixing.

I just watched this video which is really helpful.

Efly:
Thanks LarryD.

It seems that the Strand Test uses less power than my static example but my cct is wrong and needs fixing.

I just watched this video which is really helpful.

https://www.youtube.com/watch?v=EXr2_zSfnFw

Each Neopixel at full brightness draws 20mA for red, 20mA for green and 20mA for blue = 60 mA total.

60 Neopixels draw 60*60mA = 3600 mA at 5V

Where do you get 3.6 Amperes at 5V for your Neopixels?

From the 5V regulator on the NANO board you can draw 500mA = 0.5A maximum.

You will need a power adapter with a 4A/5V output rating, to fully power all 60 LEDs.

If you can provide much less power, you can drive either much less LEDs, or you can drive them at much lower brightness.