3x3 PWM LED Matrix reboots every so often

I've created a 3x3 matrix of LED's on an UNO with no additional IC's (thus a 'minimal' hardware implementation). The program uses a synchronized PWM (my own hack) to drive the cathodes as shown at:

Source code at:

http://www.tuline.com/dru/content/arduino-3x3-row-column-scan-led-matrix-pwm

The only problem I can see at the moment is that it reboots every so often, even with a 9V power supply plugged in. The limiting resistors are 330 ohm and I tried to be careful with the use of variables. Am open to suggestions on how to fix the reboot issue.

How do you know, how can you tell, that it's rebooting/rebooted?
Could what you're figuring is a reboot really be a product of your use of random?

If you blink the LED on Pin13 once in setup( ), you could establish that you are re-initialising, unless I'm missing something.

I think it's rebooting as all of the LED's turn off every minute or two and LED 13 flashes.

Add some supply decoupling.

Update:

A screw fastening the UNO to the Sparkfun plastic board seemed to be the cause of the occasional reboot. Go figure.

In addition, a decoupling capacitor between Vcc and Gnd was required to get my (now current) WS2801 project working reliably.