Go Down

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

peterengland is Here

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();
    }
   
   
}}}}}}}}}}}}}}}}}}}



Peter.

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.

peterengland is Here

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

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.


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.


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.

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

I need to change my name of account ..


peterengland is Here

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

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.

peterengland is Here

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

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy