the problem about charged by USB and alternative

Hello,

I've achieve a program that can control 9 LEDs.
When they are charged by USB, always run well; but if charged by alternative, after about 3 mins, all runs strange.

I'm new to use the arduino, I've no idea about this problem.
I use arduino Duemianove.
Thanks advance,

Most common cause, make sure ground from Arduino is connected to ground on external power supply when not being powered by usb.

So if the Arduino is charged by usb and leds are charged by external supply run a wire between the ground on the Arduino and connect it to the ground side of the external power supply.

Hope that helps.

BOZ
www.musheen.com

What voltages are you using when not connected by USB and where are you connecting them?

I'm using the AC to power the LEDs, and the LEDs are connected by I2C. The max votage input is about 12V, but I connected the ports of LEDs to ANALOG IN 4,5 and 5V, Gnd, does it matter? And I see two ports are Gnd, what's the difference between them?

And I see two ports are Gnd, what's the difference between them?

Nothing they are the same thing.
You are not giving a full description of what you have. What port expander are you using? Have you got 4k7 pull up resistors on the I2C lines? Have you any supply decoupling on the chips?