# Is there a way to invert motor direction with GCode instead of Firmware in Marlin

Is there a way to change the direction a motor goes with GCode instead of reconfiguring Marlin firmware?

• I don't understand the purpose of your question, but you can try to invert wiring of step motors instead creating another G-code or modifying the firmware. – Fernando Baltazar Jul 16 '17 at 20:48
• The purpose of inverting a motor's direction in software would be to home to a switch placed in the opposite direction of the usual one, so as to use the homing routine as a Z probe. – jbiondo Jul 17 '17 at 21:56
• So, you dont need to invert mootor direction for that porpuse, you need to indicate homing inverted. – Fernando Baltazar Jul 19 '17 at 15:52
• Yes, thank you, that makes sense. Is there a way do do that with a GCode command instead of editing the firmware? – jbiondo Jul 20 '17 at 16:45

You can use M92 to change the axis steps per unit to a negative value, which causes it to move in the opposite direction. I.e. if normally your X axis has 160 steps per mm, using M92 X-160 will invert all of its movements.