I found a working code on instructables
Instructables are crap, they are mainly written by idiots.
This particular idiot is using String which has problems with memory usage and tends to crash. It also loads in a heap of text files so it needs a large buffer
Here is some short code that will do what I said, I left the print in the code to see what it is doing. The data file is just filled up with some random hex numbers.
// Simple reading neopixels from an SD card by Mike Cook
// released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library
#include <Adafruit_NeoPixel.h>
// Which pin on the Arduino is connected to the NeoPixels?
#define PIN 6
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 6
#include <SPI.h>
#include <SD.h>
File fileptr;
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int delayval = 500; // delay for half a second
void setup() {
Serial.begin(9600);
pixels.begin(); // This initializes the NeoPixel library.
wipe();
pixels.show();
if (!SD.begin(4)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
fileptr = SD.open("test.PAT");
if (fileptr) {
Serial.println("test.PAT open");
// fileptr.close();
}
}
void nextPattern(){
byte red,green,blue;
int count = 0;
while(count < 6){
Serial.print("LED ");
Serial.print(count);
Serial.print(" - ");
red = fileptr.read();
Serial.print(red); // for seeing what is happening comment out later
Serial.print(",");
green = fileptr.read();
Serial.print(green);
Serial.print(",");
blue = fileptr.read();
Serial.print(blue);
Serial.println("");
pixels.setPixelColor(count, red,green,blue);
count ++;
}
pixels.show();
}
void loop() {
for(int i=0;i<92;i++){
Serial.println();
Serial.print("Pattern ");
Serial.println(i);
nextPattern();
delay(delayval);
}
fileptr.close();
Serial.println("file closed");
wipe();
pixels.show();
Serial.println("Finished patterns press reset to repeat");
while(true) { } // hang here with the file closed
}
void wipe(){
for(int i=0;i<pixels.numPixels();i++){
pixels.setPixelColor(i, pixels.Color(0,0,0));
}
}
This is the print out in the serial monitor
Pattern 89
LED 0 - 48,48,48
LED 1 - 48,48,10
LED 2 - 48,48,48
LED 3 - 48,48,48
LED 4 - 10,48,48
LED 5 - 48,48,48
Pattern 90
LED 0 - 48,10,48
LED 1 - 48,48,48
LED 2 - 48,48,10
LED 3 - 48,48,48
LED 4 - 48,48,48
LED 5 - 10,48,48
Pattern 91
LED 0 - 48,48,48
LED 1 - 48,10,48
LED 2 - 48,48,48
LED 3 - 48,48,10
LED 4 - 48,48,48
LED 5 - 48,48,48
file closed
Finished patterns press reset to repeat
Attached is the test pattern file to put on the SD card.
Change the file type from .TXT to .PAT because the forum won't let me upload strange extensions.
P.S. I just made up the .PAT short for pattern.
test.txt (1.65 KB)