Try to confirm with some simple Mega code (one of the examples that come with the library) without the cube effects to see if IR works. You should not "think you know what the problem is"; you need to know for sure before you continue.
If you need immediate reaction, get rid of all the delays and replace them by a millis() based approach.
It will be a lot of work as you need to break up all your cube functions in little steps. The simplest one to demonstrate how to get rid of delay_ms is probably effect_rain. It contains a nested for-loop. The inner loop does not pose an issue but the outer loop loop 100 times and hence 100 seconds delay.
This would be a reworked version to demonstrate how you can get rid of delay_ms; code not tested.
/*
effect 4 rain
In:
number of iterations
Returns:
true if all iterations completed, else false
*/
bool effect_rain (int iterations)
{
// count the number of iterations; used to be ii
static int count;
// last time that the cube was updated
static unsigned long lastUpdateTime;
PORTC = B11001100; // 4
int i;
int rnd_x;
int rnd_y;
int rnd_num;
// if number of iterations completed
if (count >= iterations)
{
// done, reset count
count = 0;
// and indicate to called that we're finished
return true;
}
if (count == 0)
{
lastUpdateTime = currentTime;
rnd_num = rand() % 4;
for (i = 0; i < rnd_num; i++)
{
rnd_x = rand() % 8;
rnd_y = rand() % 8;
setvoxel(rnd_x, rnd_y, 7);
}
}
if (currentTime - lastUpdateTime >= 1000)
{
count++;
lastUpdateTime = currentTime;
shift(AXIS_Z, -1);
}
return false;
}
Other functions are more complicated. For the effect_intro, you will need a state machine to be able to keep track which step you are executing.
In loop(), simply call effect_rain and check for IR
void loop()
{
if (irrecv.decode(&IRresults))
{
Serial.println(IRresults.value, DEC); // Print the Serial 'results.value'
irrecv.resume(); // Receive the next value
}
effect_rain()
}
Now running out of time. See if you can understand state machines.