I am running an Arduino Mega 2560 to control a 16x16 LED matrix. Each row and column of LED's is soldered to a transistor, which is, of course, controlled by the board. So far, by setting all pins (22-53) as output and then using the digitalwrite (pin(x), HIGH); function, all 256 LED's light up steady, but only when plugged into a USB power supply. However, this display is intended to be mobile, and I was hoping to power it with a 9 volt. Unfortunately, when the 9 volt is plugged in on its own, using the same code, the matrix flashes for a second, goes off, and repeats. When the USB power is supplied, the board seems to overheat and the LED's fade until cooled with a fan. Not sure what could be causing these issues, thanks for your help in advance.
It's called physics. You need to do the math. You start by getting the datasheet for the leds you are using and look up the power in watts or current in Amps (or mA) for one led. So if we were talking about a garden variety red led that draws 20mA , then
256 x 0.020A =5.12A for all 256 leds drawing 20mA each. The USB is only rated for 500mA or 0.5A (1/10th of what your array draws. You need at least a 6A 5V power supply The attached schematic is for a power supply that is rated for exactly what your load draws, 5A. You will need a heat sink for the power transistor. The schematic came from a country that uses 220V so if you are in a country that uses 120V then you need to substitute a 120V/12V transformer for the one in the schematic. The bridge rectifier is shaped like a little square hockey puck and should be mounted on a metal chassis with thermal paste . There should also be a fuse holder on the primary side of the transformer. The fuse value should be (5V x 5A)/117Vac=0.213A => 0.5A slow blow fuse.
The power transistor should be mounted on a decent size heat sink with fins using a mica insulator.
The circuit in the schematic can be replaced by a 5V 5A factory made power supply. http://www.ebay.com/itm/AC-100V-240V-DC-5V-5A-Adjust-Universal-Regulated-Switching-Power-Supply-25W-New-/350944322084?pt=LH_DefaultDomain_0&hash=item51b5e96224
Sounds like your matrix is set up for multiplexing.
So only 16 LEDs at a time should be on and you should be alternating thru the columns (or rows).
Thus power needed is only 0.02A X 16 = 320mA.
Post a schematic to confirm your setup.
You're exactly right, by multiplexing the LED's, overheating and lack of power ceased to be a problem. I assume this rapid flashing extends to other aspects of the LED programming, such as the "O" shape. I haven't had a chance to draw up a schematic; pretty new to all of this. Should be good now. Thank-you for your help.