Trouble w/ Backing Track Project

Before I unload my programming issues, thanks to the forum in advance. I’ve been building a backing track player for my band Cheap Dinosaurs. It uses an Adafruit Audio Shield and a Genesis Controller Library that i modified for an Ardunio Mega. A lot of people asked me why i don’t just use a computer with a controller attached, but let me tell you computers are completely unreliable in a music setting - the whole story is in the attached file haha. I’ve come to a pass where I simply cannot find the bug. I’m a professional musician that does not want to join the masses and perform with apple logos all over the place. Please help! I’ve attatched the code. I also think I used an earlier version of arduino. I think the adafruit library locked me into that. I would update the library if I knew how so I could use the newer version of Arduino but I really don’t have the skills for that. Does anyone know an easy way to update libraries? The issue is when i play a song - the program crashes *sometimes - not all the time. We’ve actually used it live, but restarting isn’t preferable for quick transitions. The good thing is the song doesn’t ever stop playing but to get to the next song we have to hit the restart button which can cause a pop in the PA system.

cheapdinos_player.ino (4.44 KB)

shieldKeys.ino (2.23 KB)

threeButtonKeys.ino (2.26 KB)

part 1

// This Program is for the Cheap Dinosaurs backing track player.
// We have had some issues in the past with extremely failable vintage equipment.
// We wanted something with modern functionality and a modern flare.
// We wanted to use a Genesis controller but playback high quality wav, ogg or midi.
// It also had to be durable.  Above all else we needed something that could 
// withstand high heat levels under stage lighting and also deliver great sound quality.
// equipment to use with this code:
// Arduino Mega 2560, Adafruit VS1053 Shield, Adafruit I2C LCD kit
// DB9 module, Genesis 3-Button Controller, Jumpers, Stacking Headers, Enclosure, etc.

// GENESIS 3-BUTTON LIBRARY + OBJECT
// modified library: inputs have been relocated to pins 22-28
// DB9 module used to interface with the Genesis Controller

#include <GenesisGamepad.h>
GenesisGamepad thr33Button; // create the controller jawn

// MUSIC SHIELD SHITE
// include SPI, MP3, and SD libraries
#include <SPI.h>
#include <Adafruit_VS1053.h>
#include <SD.h>
// These are the pins used for the music maker shield
#define SHIELD_RESET  9      // VS1053 reset pin (output)
#define SHIELD_CS     7      // VS1053 chip select pin (output)
#define SHIELD_DCS    6      // VS1053 Data/command select pin (output)
#define CARDCS 4     // Card chip select pin
#define DREQ 3       // VS1053 Data request, ideally an Interrupt pin
Adafruit_VS1053_FilePlayer musicPlayer = // create breakout-example object
Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS); // create shield-example object

// LOAD LCD LIBRARY + PIXEL ART
#include <Wire.h>  // for the I2C 2-wire (SDA,SCL) connection
#include <Adafruit_MCP23017.h>  // for buttons on shield
#include <Adafruit_RGBLCDShield.h> // make screen work
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield(); 

// pixel art for the transport
byte previous[8] = {
  B10011,
  B10111,
  B11111,
  B10111,
  B10011,
  B00000,
  B00000,
};
byte rewind[8] = {
  B00101,
  B01111,
  B11111,
  B01111,
  B00101,
  B00000,
  B00000,
};
byte fastForward[8] = {
  B10100,
  B11110,
  B11111,
  B11110,
  B10100,
  B00000,
  B00000,
};
byte next[8] = {
  B11001,
  B11101,
  B11111,
  B11101,
  B11001,
  B00000,
  B00000,
};
byte play[8] = {
  B11000,
  B11100,
  B11110,
  B11100,
  B11000,
  B00000,
  B00000,
};
byte st0p[8] = {
  B01110,
  B11111,
  B11111,
  B11111,
  B01110,
  B00000,
  B00000,
};
byte pause[8] = {
  B10010,
  B10010,
  B10010,
  B10010,
  B10010,
  B00000,
  B00000,
};
byte heart[8] = {
  B10101,
  B01110,
  B11111,
  B01110,
  B10101,
  B00000,
  B00000,
};

int loadDelay = 100;

int deBounce = 300;

boolean pauseFlag = true;
long cReading = 0;  // this needs to be a long to store the huge millis() number as time goes on
boolean canPawz = false;
long shieldUpReading = 0

void setup() {
  // begin serial monitor for debugging + talking to the console
  Serial.begin(9600);

  // FOR GENESIS CONTROLLER
  thr33Button.init();

  // LCD SHITE
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2); // btw THIS HAS to be first.
  // IDEA!! uint16_t decodeTime(void) - Reads the DECODETIME register from the chip.
  // load PixelArtBytes™ into LCD's createChar variable
  lcd.createChar(0, previous);
  lcd.createChar(1, rewind);
  lcd.createChar(2, fastForward);
  lcd.createChar(3, next);
  lcd.createChar(4, play);
  lcd.createChar(5, st0p);
  lcd.createChar(6, pause);
  lcd.createChar(7, heart);
  // draw transport
  lcd.setCursor(0,0);
  lcd.write(byte(0));  // previous chr
  delay(loadDelay);
  lcd.setCursor(2, 0); 
  lcd.write(byte(1));  // rewind chr
  delay(loadDelay);
  lcd.setCursor(4, 0); 
  lcd.write(byte(2));  // fast forward chr
  delay(loadDelay);
  lcd.setCursor(6, 0); 
  lcd.write(byte(3));  // next chr
  delay(200);
  lcd.setCursor(11, 0); 
  lcd.write(byte(4));  // play chr
  delay(loadDelay);
  lcd.setCursor(13, 0); 
  lcd.write(byte(5));  // stop chr
  delay(loadDelay);
  lcd.setCursor(15, 0); 
  lcd.write(byte(6));  // pause chr 

  // FOR MUSIC PLAYBACK
  Serial.println("Welcome to your Doom");
  if (! musicPlayer.begin()) { // initialise the music player
    Serial.println(F("Couldn't find VS1053, do you have the right pins defined?"));
    while (1);
  }
  Serial.println(F("VS1053 found"));
  SD.begin(CARDCS);    // initialise the SD card
  
  musicPlayer.setVolume(0,0);  // lower numbers == louder volume!
  musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT);  // DREQ int

}

void loop() {
  threeButtonKeys();
  shieldKeys();
}

animalstyle:
I've come to a pass where I simply cannot find the bug.

Are you possibly using the same Arduino pins connected to different devices?

Are you using this pinout for your "Genesis controller" (I had googled this information, you didn't post anything about the Genesis controller, library or pinout):

In that case you'd have duplicate usage.

Genesis controller uses D2, D3, D4, D5, D6, D7, D8

Your code about the music player says:
#define SHIELD_RESET 9 // VS1053 reset pin (output)
#define SHIELD_CS 7 // VS1053 chip select pin (output)
#define SHIELD_DCS 6 // VS1053 Data/command select pin (output)
#define CARDCS 4 // Card chip select pin
#define DREQ 3 // VS1053 Data request, ideally an Interrupt pin

So the pins 3, 4, 6 and 7 are in use for the Genesis controller and also used for the music player?

I'm afraid, but that will surely create trouble, at least while using "the Genesis controller" and "the music player" at the same time.

I modified the Genesis library so it won't conflict. I used an arduino mega and edited the Genesis pins to the arduino digital outs in the 20's. There is something else going on. :frowning:

animalstyle:
I modified the Genesis library so it won't conflict. I used an arduino mega and edited the Genesis pins to the arduino digital outs in the 20's. There is something else going on. :frowning:

There's a lot going on. You even tell about a third-party library, but do not use it "as is" and use a patched version of the library without telling anything about that when asking for possible problems. So in my first reply I searched that third-party library and found conflicting pin declarations, wrote a reply about conflicting pin numbers, which you already fixed without telling about. So looking for conflicting pins in the library and writing reply about that seems to be wasted effort.

One additional problem might be caused on the SPI-bus when using the SD card.

You are using the SPI bus, but there seems to be no SPI-device connected to the hardware SlaveSelect pin, but only the SD card at pin-4.

In that case you should set the hardware SlaveSelect (SS) pin to OUTPUT/LOW, before using the SD card on pin-4.

Replace in the setup() function:

 SD.begin(CARDCS);    // initialise the SD card

with this initialization:

 pinMode(SS, OUTPUT); // deactivate SPI hardware "Slave Select" pin
  SD.begin(CARDCS);    // initialise the SD card