Led matrix and sd card

Hi everyone,

I'm doing a little case for a cactus, i have different sensors and a pump to give water to him but that doesn't really matter.

Since it will be a ornament for the living room i decided to use four led matrix 8x8 to create a clock.

I also want to keep memory of different variables to see how many times it is watered and for monitoring the temperature and the moisture. So i decided to use an sd card module.

I tried the led matrix and the sd card module separately and they works.

Here is the problem, when i wirte "SD.begin(10)", the led matrix just doesn't work, it just doesn't light up, but the sd card module works.

I'm using an arduino nano with only this two modules, the pins are in the program. (they are connected to the same clock pin, 13)

the program is the merge of two example frome the library.

i dont' really know what could be the problem, i tried also different pins for the matrix so far i got the same result.

thanks for your time, i hope you have some suggestions. :slight_smile:

ReadWrite.ino (3,7 KB)

Sigh... Please post a schematic, your code and links to the components you used. Read the forum guide in the sticky post so that you know how to post those things correctly.

I suspect the problem is the 3.3V to 5V logic level shifter circuit on your SD card adapter.

Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advice on) your project.

I can't open ino files on my cell phone; please post code in a post (and please don't forget to use code tags).

Some cheap SD Card adapters don't work properly and interfere with other SPI devices. Usually, this is the chip used for 5V to 3.3V level shifting not having a tristate mode for when the SD is not selected (CS is HIGH). If that turns out to be the problem it can be fixed by either getting a properly designed module or by eliminating and bypassing the MISO/CIPO level shifter.

Ive got a logging weather clock that uses the same led matrix and sd card. Help yourself.

https://create.arduino.cc/projecthub/madmark2150/talking-alarm-clock-with-8x8x4-matrix-display-2ae9f6

Schematic: (arduino is powered by usb)


Matrix: https://www.amazon.it/HiLetgo-MAX7219-Microcontroller-Arduino-Display/dp/B0815W92L8/ref=sr_1_1?keywords=HiLetgo+LED+Dot+Matrix+Module+LED+Dot+Matrix+Microcontroller+for+Arduino+4+in+1+LED+Display+with+Dupont+Wires&qid=1661072054&sr=8-1

Sd module: https://www.amazon.it/AZDelivery-Reader-Memory-Shield-Arduino/dp/B077MB17JB/ref=sr_1_1?keywords=AZDelivery+5+x+Modulo+Lettore+SPI+Reader+Micro+Scheda+SD+TF+Memory+Card+Shield+compatibile+con+Arduino+incluso+un+E-Book!&qid=1661072028&sr=8-1

code:

#include <SPI.h>
#include <SD.h>
#include "LedControl.h"

File myFile;
LedControl lc=LedControl(7,13,6,4);

unsigned long delaytime=100;

void setup() {
  lc.shutdown(0,false);
  lc.setIntensity(0,0);
  lc.clearDisplay(0);

  Serial.begin(9600);
  while (!Serial) {
    ;
  }


  Serial.print("Initializing SD card...");

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


  myFile = SD.open("test.txt", FILE_WRITE);

  if (myFile) {
    Serial.print("Writing to test.txt...");
    myFile.println("testing 1, 2, 3.");
    myFile.close();
    Serial.println("done.");
  } else {
    Serial.println("error opening test.txt");
  }

  myFile = SD.open("test.txt");
  if (myFile) {
    Serial.println("test.txt:");

    while (myFile.available()) {
      Serial.write(myFile.read());
    }

    myFile.close();
  } else {
    Serial.println("error opening test.txt");
  }

  
}

void loop() {
  single();
}




void writeArduinoOnMatrix() {
  /* here is the data for the characters */
  byte a[5]={B01111110,B10001000,B10001000,B10001000,B01111110};
  byte r[5]={B00111110,B00010000,B00100000,B00100000,B00010000};
  byte d[5]={B00011100,B00100010,B00100010,B00010010,B11111110};
  byte u[5]={B00111100,B00000010,B00000010,B00000100,B00111110};
  byte i[5]={B00000000,B00100010,B10111110,B00000010,B00000000};
  byte n[5]={B00111110,B00010000,B00100000,B00100000,B00011110};
  byte o[5]={B00011100,B00100010,B00100010,B00100010,B00011100};

  /* now display them one by one with a small delay */
  lc.setRow(0,0,a[0]);
  lc.setRow(0,1,a[1]);
  lc.setRow(0,2,a[2]);
  lc.setRow(0,3,a[3]);
  lc.setRow(0,4,a[4]);
  delay(delaytime);
  lc.setRow(0,0,r[0]);
  lc.setRow(0,1,r[1]);
  lc.setRow(0,2,r[2]);
  lc.setRow(0,3,r[3]);
  lc.setRow(0,4,r[4]);
  delay(delaytime);
  lc.setRow(0,0,d[0]);
  lc.setRow(0,1,d[1]);
  lc.setRow(0,2,d[2]);
  lc.setRow(0,3,d[3]);
  lc.setRow(0,4,d[4]);
  delay(delaytime);
  lc.setRow(0,0,u[0]);
  lc.setRow(0,1,u[1]);
  lc.setRow(0,2,u[2]);
  lc.setRow(0,3,u[3]);
  lc.setRow(0,4,u[4]);
  delay(delaytime);
  lc.setRow(0,0,i[0]);
  lc.setRow(0,1,i[1]);
  lc.setRow(0,2,i[2]);
  lc.setRow(0,3,i[3]);
  lc.setRow(0,4,i[4]);
  delay(delaytime);
  lc.setRow(0,0,n[0]);
  lc.setRow(0,1,n[1]);
  lc.setRow(0,2,n[2]);
  lc.setRow(0,3,n[3]);
  lc.setRow(0,4,n[4]);
  delay(delaytime);
  lc.setRow(0,0,o[0]);
  lc.setRow(0,1,o[1]);
  lc.setRow(0,2,o[2]);
  lc.setRow(0,3,o[3]);
  lc.setRow(0,4,o[4]);
  delay(delaytime);
  lc.setRow(0,0,0);
  lc.setRow(0,1,0);
  lc.setRow(0,2,0);
  lc.setRow(0,3,0);
  lc.setRow(0,4,0);
  delay(delaytime);
}


void single() {
  for(int row=0;row<8;row++) {
    for(int col=0;col<8;col++) {
      delay(delaytime);
      lc.setLed(0,row,col,true);
      delay(delaytime);
      for(int i=0;i<col;i++) {
        lc.setLed(0,row,col,false);
        delay(delaytime);
        lc.setLed(0,row,col,true);
        delay(delaytime);
      }
    }
  }
}

Sorry if i didn't post this yesterday but i was in a hurry.

I think that there will be a problem using Pin 13 for the SPI clock AND for the non-SPI clock pin for the LED matrix. Move the LED clock to some other data pin.

It works... i feel so stupid ahahah. I wired them together purposely cause i knew that on the clock pin arduino send a signal every x seconds in order to coordinate the comunication among all the modules and so i tought that they must have the same clock signal.

thank you for your help <3

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.