dafruit_NeoPixel and SD card reading

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
scharpfwj
 
Posts: 2
Joined: Sun Jul 17, 2022 12:00 pm

dafruit_NeoPixel and SD card reading

Post by scharpfwj »

I am new to the Arduino and its programing. I am trying to control a string of LEDs (WS2811) with an Arduino(UNO R3). The pattern I am trying to generate is complex and I was hoping to have it stored on a SD card. I was hoping to read the SD card and use the data to determine the LED pattern. Reading data from the SD card works fine. Controlling the LEDS works fine. I can control up to 550 LEDs with no issue. However when I try to do both in the same program, I run into a problem. The "Adafruit_NeoPixel pixels()" command causes problems with the SD.open() command:

The command:
Adafruit_NeoPixel pixels(100, PIN, NEO_GRB + NEO_KHZ800);
Works fine. I can open the data file.

The command:
Adafruit_NeoPixel pixels(150, PIN, NEO_GRB + NEO_KHZ800);
executes. However it will NOT open the data file. I get "myFile" = 0.

any suggestions?

Code: Select all

// For SD card reading
#include <SPI.h>
#include <SD.h>
#define SDPIN     10 // pin for reading data from the SD card

File myFile;  // I am not sure what this does

// For LED cntrol
#include <Adafruit_NeoPixel.h>
#define PIN        6 // Pin the commands the LEDs
#define NLEDs  100 // Number of LEDs

// for reading the data file
#define FNAME  "LEDs150.txt"

// adafruit lib led control
  Adafruit_NeoPixel pixels(NLEDs, PIN, NEO_GRB + NEO_KHZ800);

void setup() {

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

  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

 if (!SD.begin(SDPIN)) {
    Serial.println("initialization failed!");
    while (1);
  }
  Serial.println("initialization done.");

 // open the file for reading:
  myFile = SD.open(FNAME);
  Serial.println(myFile);  
  if (myFile) {
    Serial.println(FNAME);
  }

  // close the file:
  myFile.close();
}


User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: dafruit_NeoPixel and SD card reading

Post by dastels »

Sounds like a memory limitation issue. The UNO has a very small amount of RAM. If you want a lot of pixels and the SD you'll need a MCU board with more memory.

Dave

User avatar
scharpfwj
 
Posts: 2
Joined: Sun Jul 17, 2022 12:00 pm

Re: dafruit_NeoPixel and SD card reading

Post by scharpfwj »

Would an Arduino DUE work?

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: dafruit_NeoPixel and SD card reading

Post by dastels »

Definitely. I'm not familiar with how the SRAM banks works but you'll have at least 16 times more of it.

Dave

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”