MIDI Light Show & PWM on All Pins

Hey guys! I have a problem that I can't seem to fix...I've run this by a few of my friends who are very experienced with Arduino, and they can't fix it either.

Basically, the code I've attached should read MIDI data over a serial connection with Hairless MIDI<->Serial and turn on LEDs based on note and velocity. The pitch of the note determines the LED and the velocity determines the brightness. I'm using 31 LEDs connected to pins 3-34 on my Arduino Mega 2560. The code should be able to dim the lights using it's own PWM timer but so far, nothing. I have a different code that allows me to turn on and off the lights with MIDI, but no dimming...it works fine but as soon as the dimming part gets added, it all stops working. I hope you guys can help me out! I've been working on this project for over a year and I really want it to be worth it. :slight_smile: Thanks!

MIDI_Light_Show_with_Dimming.ino (2.02 KB)

 for(int i = 0; i < 36; i++)
 {
   if(values[i] <= PWMTimer)
   {
     digitalWrite(i, LOW);
   }
   else
   {
     digitalWrite(i, HIGH);
   }
 }

Shouldn't you be writing pins 3 to 34 high or low? Diddling with the serial pins in this loop seems like an incredibly stupid thing to do.

Hmm, didn't think of that...good point. I'll change that. :slight_smile:

Okay just tried that..still didn't work...here's the updated code. Any other ideas?

MIDI_Light_Show_with_Dimming.ino (2.02 KB)

Do you know that the ISR is being called at all?

Forget the MIDI bit and just set up an array with a grey scale of dimmed numbers in.
Does it output them?