SHIELD vs1053 (SPI) y Pantalla 1.8 SPI

Hola a todos! Estoy haciendo un pequeño proyecto de asistente virtual y por ahora todo separado funciona sin errores.

Sin embargo debo utilizar 3 componentes que requieren el bus SPI para comunicarse:

  • Shield vs1053
  • LoRa
  • Pantalla 1.8 SPI

La idea por ahora, para poder empezar con la comunicación de distintos components SPI, es que en la pantalla aparezca un logo, luego se pinte verde por 5 segundos, después rojo por 5 segundos y después suene una canción por una hora. Me recomendaron usar millis, por eso no ocupo delay.

Tengo el siguiente código:

/*
Pines Para Pantalla:
 * LED =   3.3V
 * SCK =   13 (MEGA 52)
 * SDA =   11 (MEGA 51)
 * A0 =    2
 * RESET = 3
 * CS =    22
 * GND =   GND
 * VCC =   5V

*/

#include "Ucglib.h"
#include <ThreeWire.h>
#include <SPI.h>
#include <SdFat.h>
#include <vs1053_SdFat.h>

int PANTALLA_CS = 22;
int MP3_CS = 9;
unsigned long tiempo;
bool orden1;
bool orden2;
bool musica;

SdFat sd;
vs1053 MP3player;
Ucglib_ST7735_18x128x160_HWSPI ucg(2, 22, 3);

void crearPantalla()
{
  //CREA EL LOGO
}

void logoVerde(){
//PINTA EL LOGO VERDE
}

void logoRojo(){
//PINTA EL LOGO ROJO
}

void domaDormir(){
  //APAGA LA PANTALLA
}

//No creo que sea necesario colocar el codigo de los logos ya que no tienen problema.

void setup(){
  Serial.begin(115200);

  SPI.begin();
  tiempo = millis();
  pinMode(PANTALLA_CS,OUTPUT);
  pinMode(MP3_CS,OUTPUT);
  //PANTALLA INICIALIZADA

  digitalWrite(MP3_CS, HIGH);
  digitalWrite(PANTALLA_CS, LOW);
  domaDormir();
  crearPantalla();
  
  orden1 = true;
  orden2 = false;
  musica = false;
  
  //MP3 INCIALIZADO
  digitalWrite(PANTALLA_CS, HIGH);
  digitalWrite(MP3_CS, LOW);
  sd.begin(SD_SEL,SPI_HALF_SPEED);
  MP3player.begin();
  MP3player.setVolume(0,0);
}



void loop(void)
{
  if (orden1){
    digitalWrite(MP3_CS, HIGH);
    digitalWrite(PANTALLA_CS, LOW);
    logoVerde();
    if (millis()-tiempo > 5000){
      orden1 = false;
      orden2 = true;
      musica = false;
      tiempo = millis();
      
    }
  }
  if (orden2){
    digitalWrite(MP3_CS, HIGH);
    digitalWrite(PANTALLA_CS, LOW);
    logoRojo();
    if (millis()-tiempo > 5000){
      orden1 = false;
      orden2 = false;
      musica = true;
      tiempo = millis();
    }
  }
  if (musica){
    digitalWrite(PANTALLA_CS, HIGH);
    digitalWrite(MP3_CS, LOW);
    MP3player.playTrack(3);
    if (millis()-tiempo > 360000){
      orden1 = true;
      orden2 = false;
      musica = false;
      tiempo = millis();
    }
  }
  
  
}

Cuando corro el programa me sale el siguiente error:

If you get this error, you likely do not have a sd.begin in the main sketch, See Trouble Shooting Guide!
http://mpflaga.github.com/Sparkfun-MP3-Player-Shield-Arduino-Library/#Troubleshooting

Claramente tengo el sd.begin(...), y me meto al link pero no aparece nada que me pueda ayudar.

Y cuando corro el ejemplo, modificado me sale el siguiente error:

Can't access SD card. Do not reformat.
SD errorCode: 0X43,0X5

Busqué los errores y no encontré ninguna solución.

Cualquier persona que haya ocupado estos componentes o tengo alguna idea lo agradecería muchísimo.

Hi,
Donde esta esta instrucion en tu sketch para inicializar el sd.

Versions after 1.01.00 require the SdFat::begin() to be initialized in the main sketch.ino, as shown in the below example. This provides more immediate access to the SdCard's files by the main sketch. However, if not done there is no immediate compiler error and the sketch will lock up after as it attempts SFEMP3Shield::begin.

SdFat sd; // newly required in 1.01.00 and higher
void setup() {
  if(!sd.begin(SD_SEL, SPI_HALF_SPEED)) sd.initErrorHalt(); // newly required in 1.01.00 and higher
  if(MP3player.begin() != 0) {Serial.print(F("ERROR"));

Hola!
En el setup(), en las últimas líneas:

//MP3 INCIALIZADO
  digitalWrite(PANTALLA_CS, HIGH);
  digitalWrite(MP3_CS, LOW);
  [b]sd.begin(SD_SEL,SPI_HALF_SPEED);
  MP3player.begin();[/b]
  MP3player.setVolume(0,0);

O debo colocarlo como tu dices?

Hi,
Copiala como esta en el ejemplo. El SdFat sd; va antes del setup y las otras instrucciones van despues del setup.

Hola!

Agregué las líneas del ejemplo y me aparece el siguiente error:

Can't access SD card. Do not reformat.
No card, wrong chip select pin, or SPI problem?
SD errorCode: 0X20,0X0

Cabe destacar que la tarjeta SD funciona sin problemas con el código de ejemplo, por lo que es problema de SPI.

Hi.
Quien fabrica el MP3 Player Shield. Es el SparkFun MP3 Player Shield o Adafruit.

Específicamente es esta:

https://es.aliexpress.com/item/32965676064.html?spm=a2g0s.9042311.0.0.274263c05KQsBN

Hi,
Hice un google y encontre este web side con la misma tarjeta que tu tienes y tiene una libreria par la tarjeta. adjunto el link de donde venden la tarjeta y otro link para la libraria. Trata esa libreria para ver si te trabaja.

Link donde venden la tarjeta :VS1053 MP3 Shield ASVS1053MP Arduino Compatible Arduino Shield in Elecrow bazaar!

link de la libreria : http://www.elecrow.com/download/MP3Shield%20Library%20Demo.zip