When you power the Arduino via USB cable from your laptop the current is only limited by what the laptop will provide, maybe 500 mA. When you power the Arduino with the 12 V power supply the current is limited by what the voltage regulator can provide. That is the most common cause of the "works on USB but not on a power supply" problem. If you have some LEDs drawing a lot of current from your Arduino that's likely the problem. Try it without the high current components attached to see if the problem doesn't go away.
When I supply it with external power and just connect for 1 second the USB connector and then disconnect, the program is running well, such as if it required USB for initialization.