UNO SD WAV Player with IR remote.

Please help with my code what wrong with this code ? it only plays first wav file and stops.

#include <SD.h>                      // need to include the SD library
//#define SD_ChipSelectPin 53  //example uses hardware SS pin 53 on Mega2560
#define SD_ChipSelectPin 10  //using digital pin 4 on arduino nano 328
#include <TMRpcm.h>           //  also need to include this library...
#include <IRremote.h>
 TMRpcm tmrpcm;   // create an object for use in this sketch
char mychar;
int RECV_PIN = 6;
IRrecv irrecv(RECV_PIN);
decode_results results;
 
void setup(){
 irrecv.enableIRIn();
 tmrpcm.speakerPin = 9; //11 on Mega, 9 on Uno, Nano, etc
 Serial.begin(9600);
  if (!SD.begin(SD_ChipSelectPin)) {  // see if the card is present and can be initialized:
    Serial.println("SD fail"); 
    return;   // don't do anything more if not
  }
  //tmrpcm.play("1.wav"); //the sound file "music" will play each time the arduino powers up, or is reset
}
unsigned long last = millis();
  void loop(){ if (irrecv.decode(&results))
  {
    if (results.value == 0x40BD00FF) 
    { 
      if (millis() - last > 250) 
      {
         
        tmrpcm.play("1.wav");
      }
      last = millis();
    
    
    { if (irrecv.decode(&results))
  {
    if (results.value == 0x40BD807F) 
    { 
      if (millis() - last > 250) 
      {
         
        tmrpcm.play("2.wav");
      }
      last = millis();
    }
{ if (irrecv.decode(&results))
  {
    if (results.value == 0x40BD40BF) 
    { 
      if (millis() - last > 250) 
      {
         
        tmrpcm.play("3.wav");
      }
      last = millis();
    }  
{ if (irrecv.decode(&results))
  {
    if (results.value == 0x40BDC03F) 
    { 
      if (millis() - last > 250) 
      {
         
        tmrpcm.play("4.wav");
      }
      last = millis();
    }

{ if (irrecv.decode(&results))
  {
    if (results.value == 0x40BD20DF) 
    { 
      if (millis() - last > 250) 
      {
         
        tmrpcm.play("5.wav");
      }
      last = millis();
    }
{ if (irrecv.decode(&results))
  {
    if (results.value == 0x40BDA05F) 
    { 
      if (millis() - last > 250) 
      {
         
        tmrpcm.play("6.wav");
      }
      last = millis();
    }
    { if (irrecv.decode(&results))
  {
    if (results.value == 0x40BD609F) 
    { 
      if (millis() - last > 250) 
      {
         
        tmrpcm.play("7.wav");
      }
      last = millis();
    }
    { if (irrecv.decode(&results))
  {
    if (results.value == 0x40BDE01F) 
    { 
      if (millis() - last > 250) 
      {
         
        tmrpcm.play("8.wav");
      }
      last = millis();
    }
    
    { if (irrecv.decode(&results))
  {
    if (results.value == 0x40BD28D7) 
    { 
      if (millis() - last > 250) 
      {
         
        
      }
      last = millis();
    }
    
    
}}}}}}}}}}}}}}}}}}}
  void loop(){ if (irrecv.decode(&results))

Functions start in column 0. Nothing follows a { on the same line.

Your formatting is horrid. Fix that if you expect any help.

Formatting means what do you want to say ? pls clear i can't get your point .

Ctrl-t in the IDE

what the Ctrl-T does actually ?

It fixes abominations like this }}}}}}}}}}}}}}}}}}}

Thanks ..

But IDE returned following error .

java.lang.ArrayIndexOutOfBoundsException: 20

Is there a particular reason your IP address is the same as member "ganeshkubade"?

Yes i Am owner of that two accounts one that created just now.

I need to change my name of account ..

so i created a new one :slight_smile:

oh I don't know that is illegal ,, sorry for that,, you already banned my account :slight_smile:

If you want to change your name, change it, but don't create sock-puppets

I am very very sorry.. I never do it from now.