problem with arduino power supply

hello , i have a problem with my arduino mega and i somehow managed to blow up the ATmega8U2 on the board.
i was experimenting with stepper motors for my next project and was trying to use a PC power supply for the motors.
my project involves 2 types of steppers
the RH7-1048

and an other motor which has absolutely no marking on it, i asked my teacher and he told me it was a 12V. it looks like this

i made this schematic


the driver i used is here L298n Dual H Bridge DC Stepper Motor Drive Controller Board Module for Arduino for sale online | eBay
when i used it with the 5V motor(using the purple +5v SBY instead of the blue)
the motor worked correctly
but when i tried it with the other one(12v) all the lights on the board lit up and i heard a spark so i unplugged the supply
apparently the atmega8u2 got blown..i still cant explain myself why because the limits on the arduino are 6v-20v can somebody please explain it to me
is there something wrong with the schematic is it possible that i did a mistake when wiring it.
also the arduino is powered by that supply and that is not sometime i want so i think i am doing something wrong.

i read on the forum that someone has a similar problem where it managed to blow the ATmega8u2
also an other post where it says that the voltage regulator could be blown as well
and some things describer there apply to my case 2
1.when replugging the board into USB the Atmega8u2 gets hot pretty fast
2.the communication with the PC is dead
3.the board still works (reset blinking LED and power LED still work)
i did some research and i found a few solutions which im not sure if it will work so im asking here
should i.
-buy an other arduino(http://www.ebay.com/itm/251143019741) and somehow reprogram the old one with it when the program is completed
-attempt to change the voltage regulator
-attempt to change the ATmega8u2 which is quite the challenge and that IC is not much cheaper that buying a new mega
-attempt to use the ICSP pins on the board(which i have no idea how to do it)

thank you for your time