doesn't stop moving

I built a 3-d printer and am using the Arduino Mega 2560 R3. i checked my connections a thousand times. As soon as I turn on my machine it starts moving back and forth until i turn off the power and i can't connect with my computer. My bed and extruder heat up just fine all motors turn. Has anybody ever had this problem? is my board defective? can i do something to fix it?