Logical error

hello,
I am trying to build HAL 9000.
I am very new to programming.
I have an arduino nano, SD card reader and an IR sensor.
using https://github.com/abhijitbrain/creative-research/blob/master/_1mp3.ino and Using IR Remote Controls with Arduino | DroneBot Workshop (thank you to both of them)
i was able to come up with
#include “SD.h”
#define SD_ChipSelectPin 4
#include “TMRpcm.h”
#include “SPI.h”
#include <IRremote.h>

// Define sensor pin
const int RECV_PIN = 6;

// Define IR Receiver and Results Objects
IRrecv irrecv(RECV_PIN);
decode_results results;

TMRpcm tmrpcm;

void setup()
{
irrecv.enableIRIn();
tmrpcm.speakerPin = 9;
Serial.begin(9600);

irrecv.resume();
}

void loop()
{
if (!SD.begin(SD_ChipSelectPin))
{
Serial.println(“SD fail”);

return;
}

if (irrecv.decode(&results))
{
switch (results.value)
{
case 0xFF30CF:
tmrpcm.setVolume(5);
tmrpcm.play(“2001.wav”);
break;
case 0xFFB04F:
tmrpcm.setVolume(5);
tmrpcm.play(“cantdo.wav”);
break;
irrecv.resume();
}

}
}
My problem now is that the program only runs ones. i want it to run continuously

Please help. Thanks

The irrecv.resume(); is immediately after a break so it will never run. Try moving it outside the switch().

Steve

Still no luck. I have tried moving around few spots

Thanks Steve,
I moved it to where you suggested and added a return.
It works now
void loop()
{

if (irrecv.decode(&results))
{
switch (results.value)
{
case 0xFF30CF:
tmrpcm.setVolume(5);
tmrpcm.play(“2001.wav”);

break;

case 0xFFB04F:
tmrpcm.setVolume(5);
tmrpcm.play(“cantdo.wav”);

break;

}
irrecv.resume();
return;