Help programming project with arduino mega 2560

Hi, I’m new programming arduino and I have a problem trying to program a lcd display, BCD thumbwheel single digit code (0 to 9) and mp3 shield sparkfun, I have programmed each thing and they work fine. now I tried to program all things together and the lcd and thumbwheel switch works but when I try to play the audio with A0 input it doesn’t play the audio and I’m stuck there.

This is a project for a silhoutte shooters club. I need the thumbwheel switch to enter the number of shooters and with another switch call the shooters with audio.

attached is the code I have.

thank you

prueba.ino (1.66 KB)

#include <LiquidCrystal.h>
#include <SPI.h>
#include <SdFat.h>
#include <SFEMP3Shield.h>
#include <Bounce2.h>

#define q1 28
#define q2 26
#define q4 24
#define q8 22

#define B_PLAY A0

SdFat sd;
SFEMP3Shield MP3player;
Bounce b_Play = Bounce();
int8_t current_track = 0;

const int rs = 10, en = 5, d4 = 46, d5 = 44, d6 = 42, d7 = 40;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print(" Presiona Call");
lcd.print(" para comenzar");

Serial.println(readSwitch()); // sends switch value to serial monitor box
pinMode(q1, INPUT); // thumbwheel ‘1’
pinMode(q2, INPUT); // thumbwheel ‘2’
pinMode(q4, INPUT); // thumbwheel ‘4’
pinMode(q8, INPUT); // thumbwheel ‘8’
int readSwitch()
int total=0;
if (digitalRead(q1)==HIGH) { total+=1; }
if (digitalRead(q2)==HIGH) { total+=2; }
if (digitalRead(q4)==HIGH) { total+=4; }
if (digitalRead(q8)==HIGH) { total+=8; }
return total;




if(!sd.begin(9, SPI_HALF_SPEED)) sd.initErrorHalt();
if (!sd.chdir("/")) sd.errorHalt(“sd.chdir”);


Serial.println(F(“Looking for Buttons to be depressed…”));


void loop() {

if (b_Play.update()) {
if ( == LOW) {
Serial.print(F("B_PLAY pressed, Start Playing Track # "));


Hi Miguel, to help people help you, edit your last post and put [code] and [/code] before and after your code listing. This will format it and make sure that there are no forum-software induced errors.