Pages: [1]   Go Down
Author Topic: UNO SD WAV Player with IR remote.  (Read 923 times)
0 Members and 1 Guest are viewing this topic.
HK
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
Micro
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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



Logged

Peter.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 614
Posts: 49365
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
  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.
Logged

HK
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
Micro
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Peter.

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26313
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ctrl-t in the IDE
Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

what the Ctrl-T does actually ?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26313
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It fixes abominations like this
Code:
}}}}}}}}}}}}}}}}}}}
Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks ..
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

But IDE returned following error .

Quote
java.lang.ArrayIndexOutOfBoundsException: 20
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26313
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I need to change my name of account ..
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

so i created a new one  smiley
Logged

HK
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
Micro
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Peter.

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26313
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

"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.

HK
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
Micro
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Peter.

Pages: [1]   Go Up
Jump to: