DC Motor Speed Control

Hi, I am controlling DC motor at different speeds using L239D.
3 push buttons triggers to different speeds. This code works perfectly without DC power (12v) to motor. Each button sends the right serial value.
As soon as I connect 12 V, it reaches 255 and serial monitor hangs.

Iteration2.ino (1 KB)

post your schematic too please

I have attached the schematics

Wow big (upside down 8) ) file to open and view....

But, are the Arduino. power and 293 grounds connected together?

Yes all the grounds are connected together

Are you sure you have the logic 5V to the right pin on the 293?- you have it shown in the correct place on your drawing, opposite pin 1, but with the wrong number: it's 16 not 9.

Pin is connected to 16 and still I am getting the same error.

As soon as I power up the DC of 12V. Arduino COM ports and motor stops.

Thanks guys all of them. I read lots of topics and i controlled two dc motors.