Go Down

Topic: UNO SD WAV Player with IR remote. (Read 2930 times) previous topic - next topic

ganeshkubade

Please help with my code what wrong with this code ? it only plays first wav file and stops.
Code: [Select]
#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();
    }
   
   
}}}}}}}}}}}}}}}}}}}




PaulS

Code: [Select]
  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.
The art of getting good answers lies in asking good questions.

ganeshkubade

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

AWOL

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

peterengland


AWOL

It fixes abominations like this
Code: [Select]
}}}}}}}}}}}}}}}}}}}
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.


peterengland

But IDE returned following error .

Quote
java.lang.ArrayIndexOutOfBoundsException: 20

AWOL

Is there a particular reason your IP address is the same as member "ganeshkubade"?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

peterengland

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

peterengland

I need to change my name of account ..

peterengland


ganeshkubade

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

AWOL

If you want to change your name, change it, but don't create sock-puppets
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

ganeshkubade

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

Go Up