Marlin G and M codes

⌘K
  1. Home
  2. Docs
  3. Marlin G and M codes
  4. M Codes

M Codes

1.0.0-beta motion

M0-M1 – Unconditional stop

Stop and wait for user

 1.1.2 controlSPINDLE_LASER_ENABLE

M3 – Spindle CW / Laser On

Set the spindle CW speed or laser power

M4 – Spindle CCW / Laser On

Set the spindle CCW speed or laser power

M5 – Spindle / Laser Off

Turn off spindle or laser

 Coolant Controls

M7-M9 – Coolant Controls

Turn mist or flood coolant on / off

 2.0.0 safetyEXPECTED_PRINTER_CHECK

M16 – Expected Printer Check

Prevent G-code usage on the wrong machine

 control

M17 – Enable Steppers

Enable steppers

M18, M84 – Disable steppers

Disable steppers (same as M84).

 sdcardSDSUPPORT

M20 – List SD Card

List the contents of the SD Card.

M21 – Init SD card

Attempt to detect an SD card in the slot.

M22 – Release SD card

Simulate ejection of the SD card

M23 – Select SD file

Select an SD file to be executed

M24 – Start or Resume SD print

Start or resume a file selected with [`M23`](/docs/gcode/M023.html)

M25 – Pause SD print

Pause printing from the SD card

M26 – Set SD position

Set the SD read position

 sdcardSDSUPPORT

M27 – Report SD print status

Print SD progress to serial

 sdcardSDSUPPORT

M28 – Start SD write

Start writing to a file on the SD card

 sdcardSDSUPPORT

M29 – Stop SD write

Stop writing the file, end logging.

 sdcard

M30 – Delete SD file

Delete a specified file from SD.

 printjob

M31 – Print time

Report the current print time.

 sdcardSDSUPPORT

M32 – Select and Start

Begin an SD print from a file.

 1.0.2 sdcardSDSUPPORTLONG_FILENAME_HOST_SUPPORT

M33 – Get Long Path

Convert a short pathname to a long pathname.

 1.1.0 sdcardSDSUPPORTSDCARD_SORT_ALPHA

M34 – SDCard Sorting

Set SDCard file sorting options.

 control

M42 – Set Pin State

Set an analog or digital pin to a specified state.

 debugPINS_DEBUGGING

M43 T – Toggle Pins

Get information about pins.

 debugPINS_DEBUGGING

M43 – Debug Pins

Get information about pins.

 calibrationZ_MIN_PROBE_REPEATABILITY_TEST

M48 – Probe Accuracy Test

Measure Z Probe repeatability.

 1.1.7 lcdLCD_SET_PROGRESS_MANUALLY

M73 – Set Print Progress

Set current print progress percentage for LCD.

 printjob

M75 – Start Print Job Timer

Start the print job timer.

 printjob

M76 – Pause Print Job

Pause the print job timer.

 printjob

M77 – Stop Print Job Timer

Stop the print job timer.

 printjobPRINTCOUNTER

M78 – Print Job Stats

Print statistics about print jobs.

 controlPSU_CONTROL

M80 – Power On

Turn on the power supply

 controlPSU_CONTROL

M81 – Power Off

Turn off the power supply.

 units

M82 – E Absolute

Set E to absolute positioning.

 units

M83 – E Relative

Set E to relative positioning.

 control

M85 – Inactivity Shutdown

Set the inactivity timeout.

 motion

M92 – Set Axis Steps-per-unit

Set the number of steps-per-mm or steps-per-inch.

 debugM100_FREE_MEMORY_WATCHER

M100 – Free Memory

Observe memory used by code

 internalPOWER_LOSS_RECOVERY

M1000 – Internal Use Only

Resume from Power Loss

 internalSDSUPPORT

M1001 – Internal Use Only

Run SD Print Finishing Actions

 thermal

M104 – Set Hotend Temperature

Set a new target hot end temperature.

 thermal

M105 – Report Temperatures

Send a temperature report to the host.

 thermalEXTRA_FAN_SPEED

M106 – Set Fan Speed

Turn on the fan and set its speed

 thermal

M107 – Fan Off

Turn off a fan

 control

M108 – Break and Continue

Break out of the current waiting loop

 thermal

M109 – Wait for Hotend Temperature

Wait for the hot end to reach its target.

 hosts

M110 – Set Line Number

Set the current line number.

 hosts

M111 – Debug Level

Report and optionally set the debug flags.

 safety

M112 – Emergency Stop

Shut everything down and halt the machine.

 hostsHOST_KEEPALIVE_FEATURE

M113 – Host Keepalive

Get or set the host keepalive interval.

 hosts

M114 – Get Current Position

Report the current tool position to the host.

 hosts

M115 – Firmware Info

Print the firmware info and capabilities.

 lcdULTRA_LCD

M117 – Set LCD Message

Set the message line on the LCD.

 hosts

M118 – Serial print

Send text to serial

 debug

M119 – Endstop States

Report endstop and probe states to the host.

 control

M120 – Enable Endstops

Enable endstops and keep them enabled when not homing.

 control

M121 – Disable Endstops

Disable endstops and keep them enabled when not homing.

 1.1.7 debugHAS_TRINAMIC_CONFIG

M122 – TMC Debugging

Get TMC Debug Info

 nozzlePARK_HEAD_ON_PAUSE

M125 – Park Head

Save current position and move to filament change position.

 baricudaBARICUDA

M126 – Baricuda 1 Open

Open the valve for Baricuda 1.

 baricudaBARICUDA

M127 – Baricuda 1 Close

Close the valve for Baricuda 1.

 baricudaBARICUDA

M128 – Baricuda 2 Open

Open the valve for Baricuda 2.

 baricudaBARICUDA

M129 – Baricuda 2 Close

Close the valve for Baricuda 2.

 thermal

M140 – Set Bed Temperature

Set a new target bed temperature.

 thermal

M141 – Set Chamber Temperature

Set a new target chamber temperature.

 lcdNEWPANEL

M145 – Set Material Preset

Set material presets in the LCD menu.

 units

M149 – Set Temperature Units

Set temperature units to Celsius, Fahrenheit, or Kelvin.

 lcdBLINKM|RGB_LED|RGBW_LED|NEOPIXEL_LED|PCA9632

M150 – Set RGB(W) Color

Set the color of the RGB(W) LED, backlight, or LED strip.

 hostsAUTO_REPORT_TEMPERATURESEXTENDED_CAPABILITIES_REPORT

M155 – Temperature Auto-Report

Auto-report temperatures to host periodically.

 mixingMIXING_EXTRUDER

M163 – Set Mix Factor

Set a single mix factor for a mixing extruder.

 mixingMIXING_EXTRUDERMIXING_VIRTUAL_TOOLS

M164 – Save Mix

Save the current mix as a virtual tool.

 mixingMIXING_EXTRUDERDIRECT_MIXING_IN_G1

M165 – Set Mix

Set all mix factors for the mixing extruder.

 2.0.0 mixingMIXING_EXTRUDERGRADIENT_MIX

M166 – Gradient Mix

Set a Gradient Mix

 thermal

M190 – Wait for Bed Temperature

Wait for the bed to reach target temperature.

 thermal

M191 – Wait for Chamber Temperature

Wait for the chamber to reach target temperature.

 2.0.6.2 calibrationPROBE_TEMP_COMPENSATION

M192 – Wait for Probe temperature

Wait for the probe temperature sensor to reach a target

 motion

M200 – Set Filament Diameter

Set the diameter for volumetric extrusion.

 motion

M201 – Set Print Max Acceleration

Set maximum acceleration for print moves one or more axes.

 motion

M203 – Set Max Feedrate

Set maximum feedrate for one or more axes.

 motion

M204 – Set Starting Acceleration

Set the starting acceleration for moves by type.

 motion

M205 – Set Advanced Settings

Set some advanced settings related to movement.

 motionHAS_HOME_OFFSET

M206 – Set Home Offsets

Apply a persistent offset

 motionFWRETRACT

M207 – Set Firmware Retraction

Set options for firmware-based retraction.

 motionFWRETRACT

M208 – Firmware Recover

Firmware-retraction recover settings.

 motionFWRETRACT

M209 – Set Auto Retract

Enable / disable auto-retraction.

 motion(MIN|MAX)_SOFTWARE_ENDSTOPS

M211 – Software Endstops

Set and/or get the software endstops state

 2.0.0 calibrationEXTRUDERS > 1

M217 – Filament swap parameters

Set length and speed for filament swapping

 calibrationEXTRUDERS>1

M218 – Set Hotend Offset

Set the offset of a hotend (from hotend 0).

 motion

M220 – Set Feedrate Percentage

Set the global feedrate percentage.

 motion

M221 – Set Flow Percentage

Set the flow percentage, which applies to all E moves.

 control

M226 – Wait for Pin State

Wait for a pin to have a given state.

 extrasPHOTO_GCODE

M240 – Trigger Camera

Trigger a camera shutter

 lcdHAS_LCD_CONTRAST

M250 – LCD Contrast

Set and/or get the LCD contrast.

 i2cEXPERIMENTAL_I2CBUS

M260 – I2C Send

Send data to the I2C bus.

 i2cEXPERIMENTAL_I2CBUS

M261 – I2C Request

Request and echo bytes from the I2C bus.

 servosNUM_SERVOS>0

M280 – Servo Position

Set or get a servo position.

 servosEDITABLE_SERVO_ANGLES

M281 – Edit Servo Angles

Set servo deploy and/or stow angles

 1.1.7 calibrationBABYSTEPPING

M290 – Babystep

Babystep one or more axes

 lcdSPEAKER

M300 – Play Tone

Play a single tone, buzz, or beep.

 thermalPIDTEMP

M301 – Set Hotend PID

Set PID values for a hotend.

 thermalPREVENT_COLD_EXTRUSION

M302 – Cold Extrude

Set minimum extrusion temperature, allow cold extrusion.

 thermalPIDTEMP|PIDTEMPBED

M303 – PID autotune

Auto-tune the PID system to find stable values.

 thermalPIDTEMPBED

M304 – Set Bed PID

Set PID values for the heated bed.

 thermaltemperature sensor `1000`

M305 – User Thermistor Parameters

Set (or report) custom thermistor parameters

 controlHAS_MICROSTEPS

M350 – Set micro-stepping

Set micro-stepping for drivers that support it

 controlHAS_MICROSTEPS

M351 – Set Microstep Pins

Directly set the micro-stepping pins

 controlCASE_LIGHT_PIN

M355 – Case Light Control

Turn the case light on or off, set brightness

 controlMORGAN_SCARA

M360 – SCARA Theta A

Move to Theta A

 controlMORGAN_SCARA

M361 – SCARA Theta-B

Move to Theta-B

 controlMORGAN_SCARA

M362 – SCARA Psi-A

Move to Psi-A

 controlMORGAN_SCARA

M363 – SCARA Psi-B

Move to Psi-B

 controlMORGAN_SCARA

M364 – SCARA Psi-C

Move to Psi-C

 noneEXT_SOLENOID

M380 – Activate Solenoid

Activate

 noneEXT_SOLENOID

M381 – Deactivate Solenoids

Deactivate all extruder solenoids

 motion

M400 – Finish Moves

Wait for all moves to finish

 calibrationHAS_BED_PROBE

M401 – Deploy Probe

Deploy the bed probe

 calibrationHAS_BED_PROBE

M402 – Stow Probe

Stow the bed probe

 controlPRUSA_MMU2

M403 – MMU2 Filament Type

Set filament type for Multi-Material Unit 2.0

 controlFILAMENT_WIDTH_SENSOR

M404 – Set Filament Diameter

Set the nominal diameter for filament width sensor auto-flow

 controlFILAMENT_WIDTH_SENSOR

M405 – Filament Width Sensor On

Enable filament width sensor flow control

 controlFILAMENT_WIDTH_SENSOR

M406 – Filament Width Sensor Off

Disable filament width sensor flow control

 controlFILAMENT_WIDTH_SENSOR

M407 – Filament Width

Report the measured filament width

 motion

M410 – Quickstop

Stop all steppers instantly

 2.0.0 controlFILAMENT_RUNOUT_SENSOR

M412 – Filament Runout

Enable / disable filament runout detection

 2.0.0 controlPOWER_LOSS_RECOVERY

M413 – Power-loss Recovery

Enable / disable power-loss recovery

 motionAUTO_BED_LEVELING_(3POINT|LINEAR|BILINEAR|UBL)|MESH_BED_LEVELING

M420 – Bed Leveling State

Get and/or set bed leveling state and parameters

 motionAUTO_BED_LEVELING_(BILINEAR|UBL)|MESH_BED_LEVELING

M421 – Set Mesh Value

Set a single mesh Z height

 calibrationZ_STEPPER_AUTO_ALIGN

M422 – Set Z Motor XY

Set a Z motor position for G34 Auto-Alignment

 calibrationBACKLASH_COMPENSATIONBACKLASH_GCODE

M425 – Backlash compensation

Enable and tune backlash compensation

 motionHAS_HOME_OFFSET

M428 – Home Offsets Here

Set home offsets based on current position

 thermaleither POWER_MONITOR_CURRENT or POWER_MONITOR_VOLTAGE

M430 – Power Monitor

Read and display current (A), voltage (V), and power (W)

 sdcardCANCEL_OBJECTS

M486 – Cancel Objects

Identify and cancel objects

 eepromEEPROM_SETTINGS

M500 – Save Settings

Save settings to EEPROM.

 eepromEEPROM_SETTINGS

M501 – Restore Settings

Restore settings from EEPROM.

 eeprom

M502 – Factory Reset

Restore all settings to factory defaults.

 eeprom

M503 – Report Settings

Report all settings that may be saved to EEPROM.

 eepromEEPROM_SETTINGS

M504 – Validate EEPROM contents

Validate the contents of the EEPROM.

 2.0.6.1 securityPASSWORD_FEATURE

M510 – Lock Machine

Lock the machine if it has a passcode

 2.0.6.1 securityPASSWORD_FEATURE

M511 – Unlock Machine

Unlock the machine if it has a passcode

 2.0.6.1 securityPASSWORD_FEATURE

M512 – Set Passcode

Set a numeric passcode for locking the machine

 2.0.0 sdcardSDSUPPORT

M524 – Abort SD print

Abort an SD print started with [`M24`](/docs/gcode/M024.html)

 sdcardSDSUPPORTSD_ABORT_ON_ENDSTOP_HIT

M540 – Endstops Abort SD

Abort SD printing when an endstop is triggered.

 2.0.0 noneTMC2130|TMC2208|TMC2209

M569 – Set TMC stepping mode

Toggle stealthChop

 2.0.0 hostsBAUD_RATE_GCODE

M575 – Serial baud rate

Change the serial baud rate

 1.1.0 filamentADVANCED_PAUSE_FEATURE

M600 – Filament Change

Automatically change filament

 1.1.0 filamentADVANCED_PAUSE_FEATURE

M603 – Configure Filament Change

Configure automatic filament change parameters

 controlDUAL_NOZZLE_DUPLICATION_MODE|DUAL_X_CARRIAGE

M605 – Dual Nozzle Mode

Set the behavior mode for dual nozzles

 noneMORGAN_SCARA|MAKERARM_SCARA

M665 – SCARA Configuration

Set SCARA geometry values

 noneDELTA

M665 – Delta Configuration

Set delta geometry values

 calibration(X|Y|Z)_DUAL_ENDSTOPS

M666 – Set dual endstop offsets

Set dual endstop offsets

 calibrationDELTA

M666 – Set Delta endstop adjustments

Set Delta endstop adjustments

 controlDUET_SMART_EFFECTORSMART_EFFECTOR_MOD

M672 – Test Speed Warning

Set/clear Duet Smart Effector sensitivity

 controlNOZZLE_PARK_FEATUREADVANCED_PAUSE_FEATUREFILAMENT_LOAD_UNLOAD_GCODES

M701 – Load filament

Load filament

 controlNOZZLE_PARK_FEATUREADVANCED_PAUSE_FEATUREFILAMENT_LOAD_UNLOAD_GCODES

M702 – Unload filament

Unload filament

 2.0.5.2 thermalCONTROLLER_FAN_EDITABLE

M710 – Controller Fan settings

Set or report controller fan settings

 debugMAX7219_DEBUG

M7219 – MAX7219 Control

Control Max7219 Segmented LEDs

 2.0.8 noneGCODE_REPEAT_MARKERS

M808 – Repeat Marker

Set or go to a marker for looping G-code

GCODE_MACROS

M810-M819 – G-code macros

Set/execute one of ten G-code macros

 noneHAS_BED_PROBE

M851 – XYZ Probe Offset

Set the Z probe XYZ offset from nozzle

 calibration

M852 – Bed Skew Compensation

Misalignment in the XYZ axes.

 1.0.0-beta encoderI2C_POSITION_ENCODERS

M860-M869 – I2C Position Encoders

I2C position encoders for closed loop control

 calibrationPROBE_TEMP_COMPENSATION

M871 – Probe temperature config

Configure probe temperature compensation

 hostsHOST_PROMPT_SUPPORT

M876 – Handle Prompt Response

Handle Host prompt responses

 controlLIN_ADVANCE

M900 – Linear Advance Factor

Get and set Linear Advance K value

 noneTMC2130TMC2208TMC2660

M906 – TMC Motor Current

Set the motor current (in milliamps)

 controlDIGIPOTSS_PIN|HAS_MOTOR_CURRENT_PWM|DIGIPOT_I2C|DAC_STEPPER_CURRENT

M907 – Set Motor Current

Set motor current via digital trimpot

 controlDAC_STEPPER_CURRENT|DIGIPOTSS_PIN

M908 – Set Trimpot Pins

Set a digital trimpot directly

 controlDAC_STEPPER_CURRENT

M909 – DAC Print Values

Report DAC current values to host

 controlDAC_STEPPER_CURRENT

M910 – Commit DAC to EEPROM

Commit digipot/DAC value to external EEPROM

 controlTMC2130|TMC2208|TMC2209|TMC2660MONITOR_DRIVER_STATUS

M911 – TMC OT Pre-Warn Condition

Driver overtemperature pre-warn condition

 controlTMC2130|TMC2208|TMC2209|TMC2660MONITOR_DRIVER_STATUS

M912 – Clear TMC OT Pre-Warn

Clear overtemperature pre-warn condition flag

 controlTMC2130|TMC2208|TMC2209HYBRID_THRESHOLD

M913 – Set Hybrid Threshold Speed

TMC driver switching to spreadCycle

 controlSENSORLESS_HOMING

M914 – TMC Bump Sensitivity

Set sensorless homing sensitivity

 controlTMC2130TMC_Z_CALIBRATION

M915 – TMC Z axis calibration

Align ends of the Z axis and test torque

 L6474MONITOR_L6470_DRIVER_STATUS

M916 – L6474 Thermal Warning Test

Find L6474 drive level (KVAL_HOLD) threshold

 L6474MONITOR_L6470_DRIVER_STATUS

M917 – L6474 Overcurrent Warning Test

Find L6474 minimum current thresholds

 L6474MONITOR_L6470_DRIVER_STATUS

M918 – L6474 Speed Warning Test

Find L6474 speed threshold

 sdcard

M928 – Start SD Logging

Log serial input to an SD file

 calibrationMAGNETIC_PARKING_EXTRUDER

M951 – Magnetic Parking Extruder

Set / report Magnetic Parking Extruder settings

 sdcardHAS_SPI_FLASHSDSUPPORTMARLIN_DEV_MODE

M993-M994 – SD / SPI Flash

load or back up SPI Flash and SD

 calibrationTOUCH_SCREEN_CALIBRATION

M995 – Touch Screen Calibration

Touch screen calibration for TFT display

 2.0.0 control

M997 – Firmware update

Perform in-application firmware update

 control

M999 – STOP Restart

Return the machine to Running state

 control

T0-T6 – Select Tool Switch to the specified tool