These Marlin commands reach the printer’s hardware: pins, servos, lights, sound, the display, the I2C bus, stepper drivers, the network and the firmware itself. Each exists only when the option named is built in. A wrong pin or driver value can damage hardware.
M42 and M226: set a pin or wait for it
Both need DIRECT_PIN_CONTROL.
| Command | Parameters | Meaning |
|---|---|---|
M42 | S state, required: 0 to 255 on a PWM pin; P pin: digital pin number, also for analogue pins, LED_PIN if omitted; T mode (since 2.0.5.2, written M before 2.0.9.4): 0 input, 1 output, 2 input with pull-up, 3 input with pull-down; I 0/1 (since 1.1.9.1): ignore the protection of pins Marlin is using | Set a pin |
M226 | P pin, required; S state: 0 or 1, default -1 for inverted | Wait until the pin has the state |
M42 P44 S128 ; pin 44, PWM at half duty
M43: pin debugging
With PINS_DEBUGGING, which can be left out of production builds.
Alone, M43 reports every pin assignment.
| Parameter | Meaning |
|---|---|
P pin | Report that pin only |
I | Show values of protected pins too |
W | Watch the pin, or all pins, for changes. It loops, blocking further commands, until the board is reset, or until M108 with EMERGENCY_PARSER |
E 0/1 | Watch the endstops |
S | Test a BLTouch type servo probe, on the servo given by P, 0 to 3, default 0 |
T | Toggle pins, with the parameters below |
M43 T parameter | Meaning |
|---|---|
S pin | First pin, default 0 |
L pin | Last pin, default the highest |
R count | Toggles of each pin, default 1 |
W ms | Wait between transitions, default 500 |
I | Ignore pin protection; use with care |
M43 T S3 L6 R5 W1000 ; pins 3 to 6, five times, one second
M280 to M282: servos
| Command | Parameters | Meaning |
|---|---|---|
M280 | P index, required; S position: omit to read the position | Set or report a servo; needs NUM_SERVOS of at least 1 |
M281 | P index, required; L degrees: deploy angle; U degrees: stow angle | Since 2.0.0, with EDITABLE_SERVO_ANGLES: set the angles, or report them without L and U; stored in EEPROM |
M282 | P index, required | Since 2.0.9.2, with SERVO_DETACH_GCODE: cut the servo’s power until its next move |
M281 P0 L90 U0
M282 P1
M150 and M355: lights
M150 sets an RGB or RGBW LED, backlight or strip (BlinkM,
RGB_LED, RGBW_LED, NeoPixel, PCA9632 or PCA9533).
Colour components left out become 0 unless K is given, and a letter
without a number means 255.
M150 parameter | Meaning |
|---|---|
R, U, B 0–255 | Red, green, blue |
W 0–255 | White, where there is a white channel |
P 0–255 | NeoPixel brightness; unchanged if omitted |
I index | Since 2.0.6: one NeoPixel, counted from 0 |
S 0/1 | Since 2.0.6.1, with NEOPIXEL2_SEPARATE: strip; default NEOPIXEL_M150_DEFAULT, where -1 means both |
K | Keep unspecified values |
M355, with CASE_LIGHT_ENABLE, controls the case light:
S 0/1 off or on, P 0–255
brightness. Alone it reports the state. Only the brightness is saved to
EEPROM.
M150 B30 ; dim blue
M150 K R127 ; change red only
M355 S1 P128 ; case light at half brightness
M250, M255, M256 and M300: display and sound
| Command | Parameters | Meaning |
|---|---|---|
M250 | C contrast | Set or report display contrast, limited to the display’s range; EEPROM |
M255 | S minutes | Since 2.0.9.4: set or report the sleep or backlight timeout; EEPROM |
M256 | B 0–255 | Since 2.0.9.2: set or report brightness, usually 0 dimmest; EEPROM |
M300 | S Hz: frequency, with 260 given beside it; P ms: duration, with 1 given beside it | Add a tone to the queue; tones rather than plain beeps need SPEAKER |
M300 S440 P200
M300 S660 P250
M240: camera trigger
With PHOTO_GCODE: fire the shutter through a pin, or by driving
the head into a switch. Most parameters need PHOTO_POSITION.
| Parameter | Meaning |
|---|---|
X, Y position | Photo position |
Z length | Z raise |
A, B offset | Offset of the return position in X and Y |
F feedrate | Feed rate of the moves in mm/min; otherwise the probing feed rate in XY and the homing feed rate in Z |
R length, S feedrate | Retraction length and feed rate |
P ms | Delay before returning, default PHOTO_DELAY_MS |
D ms | How long to hold the shutter switch or CHDK_PIN, default PHOTO_SWITCH_MS |
I, J position | With PHOTO_SWITCH_POSITION: X and Y of the switch |
M260, M261 and M265: I2C bus
M260 and M261 need EXPERIMENTAL_I2CBUS
and are marked experimental.
| Command | Parameters | Meaning |
|---|---|---|
M260 | A address; B byte: add to the buffer; R: reset and rewind the buffer; S: send it | Send bytes |
M261 | A address and B count, both required; S style (since 2.0.9.3): 0 raw echo (default), 1 bytes in hexadecimal, 2 a one or two byte value in decimal, 3 bytes in decimal | Request bytes and echo them to the host |
M265 | None | Since 2.1.3, with I2C_SCANNER: scan the external bus, addresses 0x08 to 0x77, and list devices |
M260 A99 ; address
M260 B77 ; a byte for the buffer
M260 S1 ; send
M261 A99 B5 ; reads like: i2c-reply: from:99 bytes:5 data:hello
M380 and M381: solenoids
With EXT_SOLENOID or MANUAL_SOLENOID_CONTROL.
M380 activates the solenoid of the active extruder.
M381 deactivates all of them. Since 2.0.0, with manual control,
S index names one solenoid for either command.
M906 to M910: motor currents
| Command | Parameters | Meaning |
|---|---|---|
M906 | X, Y, Z, E mA; I index: 1 for X2, Y2 and Z2, 2 for Z3, 3 for Z4; T tool: extruder, E0 by default | Set Trinamic driver currents (also L64xx before 2.1.2); alone, report them; EEPROM. The documentation marks I as required but shows the command without it |
M907 | X, Y, Z, E current; B, C, D: E1, E2, E3; I, J, K, U, V, W: further axes; S: all steppers | Set current through a digital trimpot, DAC or PWM; the unit depends on the hardware, as does which letters exist. With MOTOR_CURRENT_PWM_XY, X covers Y as well; EEPROM |
M908 | P address (pin or channel) and S current, both required | Write a trimpot or DAC channel directly |
M909 | None | Report the DAC currents |
M910 | None | Since 1.1.0: save the DAC values to its EEPROM over I2C |
M920 | X, Y, Z, A, B, C, U, V, W mA; I index as for M906, all if omitted | Since 2.1.3, with EDITABLE_HOMING_CURRENT: set or report the current used while homing, an alias of M906 H; EEPROM |
M906 I1 X800 ; X2 driver
M920 X660 Y660 ; homing currents
M569, M911 to M915 and M919: Trinamic drivers
| Command | Parameters | Meaning |
|---|---|---|
M569 | S 0/1; axes X, Y, Z, E; I index: 1 for second steppers, 2 for Z3; T tool: extruder | Since 2.0.0, TMC2130, 2208 or 2209: S1 selects stealthChop, S0 spreadCycle; alone, report; EEPROM |
M911 | None | With MONITOR_DRIVER_STATUS: report the over-temperature pre-warning |
M912 | X, Y, Z n: 1, 2 or 3 selects the first, second or third stepper, none all; E index: one extruder, or all; I n: 0 both, 1 base, 2 second, 3 third | Clear that flag; alone, clear every one |
M913 | X, Y, Z, E, A, B, C, U, V, W speed; I index; T tool. At least one | With HYBRID_THRESHOLD: the speed above which a driver leaves stealthChop for spreadCycle; EEPROM |
M914 | X, Y, Z, A, B, C, U, V, W value; I index | With SENSORLESS_HOMING: stall sensitivity. TMC2209: 0 to 255, higher more sensitive. TMC2130: -64 to 63, lower more sensitive. EEPROM |
M915 | S mA: current, default CALIBRATION_CURRENT; Z distance: past Z_MAX_POS, default CALIBRATION_EXTRA_HEIGHT | Deprecated since 2.0.0 in favour of G34: square the X gantry by driving Z against the top, deliberately stalling, then home Z again |
M919 | O 1–15: off time; P -3–12: hysteresis end; S 1–8: hysteresis start; axis letters X, Y, Z, A, B, C, U, V, W; I index; T tool | Since 2.0.9.4: set or report chopper timing; omitted values use the configured defaults |
M912 X1 E1 ; clear X and E1
M919 XYZE O3 P-1 S1 ; the documentation’s 12 V example
M350 and M351: microstep pins
For boards with digital microstepping pins (HAS_MICROSTEPS).
| Command | Parameters | Meaning |
|---|---|---|
M350 | X, Y, Z, E (E0), B (fifth driver), A, C, U, V, W: 1, 2, 4, 8 or 16; S: the same for all five drivers | Set microstepping |
M351 | S 1/2, required: pin MS1 or MS2; X, Y, Z, E, B 0/1 | Set those pins directly |
M351 S1 X1 E0 ; set X_MS1, clear E0_MS1
M916 to M918: L6474 driver tests
These test routines need MONITOR_L6470_DRIVER_STATUS and assume
matching chips on each axis. An axis letter gives the distance, 1 to 255 mm to
either side of the current position, over which it is moved. J
picks drivers on a multiple driver axis: 0 all (default), 1 the first set (X,
Y, Z, E1), 2 the second (X2, Y2, Z2, E2), 3 to 7 only Zn and
En. T is the TVAL current, 0 to 4 A in steps of
31.25 mA, rounded down (L6474 only), and K is
KVAL_HOLD, 0 to 255 (not L6474); omitted, they are read from the
driver.
| Command | Parameters | Test |
|---|---|---|
M916 | X, Y, Z, E, J, T, K; F feedrate, maximum if omitted; D seconds per setting, 0 for once each | Raise the drive level until a thermal warning |
M917 | X, Y, Z, E, A, B, C, U, V, W, J, T, K; F feedrate; I threshold: starting overcurrent threshold | Find the lowest current thresholds: lower the overcurrent threshold until it errs and raise it again, then the same with the stall threshold (not on L6474) |
M918 | X, Y, Z, E, J, T, K; I threshold: overcurrent; M 1–128: microsteps | Raise the speed until an error or the maximum feed rate |
M550 to M554 and M587: name and network
| Command | Parameters | Meaning |
|---|---|---|
M550 | P "name", or the name alone as a string, quoted if it starts with P | With CONFIGURABLE_MACHINE_NAME: set the machine name, or report it as RepRap name: …; EEPROM |
M552 | P address: IP address, 0.0.0.0 for DHCP; S n: -1 reset, 0 disable, 1 enable | Since 2.0.8, with Ethernet: address and interface state; EEPROM |
M553 | P mask | Since 2.0.8: subnet mask; EEPROM |
M554 | P address | Since 2.0.8: gateway; EEPROM |
M587 | S ssid: network to join or to host; P password, P"" for an open network; A 0/1: join or be an access point, unchanged if omitted; U: update the module from MksWifi.bin on the media | Since 2.1.3, with MKS_WIFI_MODULE: set the Wi-Fi network at once; alone, report SSID and mode, never the password. M500 saves. U takes up to a minute and is refused while printing |
Without GCODE_QUOTED_STRINGS the first parameter of
M587 that is not a number takes the rest of the line, so only one
string fits and A must come first.
M552 S-1 P192.168.1.55
M553 P255.255.255.192
M587 A0 SMyNetwork
M587 PMyPassword
M510 to M512: passcode
Since 2.0.6.1, with PASSWORD_FEATURE. The passcode is a number of
up to nine digits, its length set by PASSWORD_LENGTH.
| Command | Parameters | Meaning |
|---|---|---|
M510 | None | Lock the machine |
M511 | P passcode, required | With PASSWORD_UNLOCK_GCODE: unlock, printing Incorrect Password if wrong and nothing if right |
M512 | P passcode: the current one; S passcode: the new one | With PASSWORD_CHANGE_GCODE: check P, then clear the passcode, or set it to S |
M540, M672, M951 and M7219
| Command | Parameters | Meaning |
|---|---|---|
M540 | S 0/1, required | With SD_ABORT_ON_ENDSTOP_HIT: whether an endstop hit aborts printing from the card; the endstops must be enabled (M120) |
M672 | One of S 0–255: sensitivity, or R: factory setting | Since 2.0.2, with DUET_SMART_EFFECTOR and its modify pin: program the Duet Smart Effector. Marlin’s form differs from Duet firmware’s |
M951 | L, R position: the two X parking positions; I distance: grab distance; J, H speed: slow and fast feed rates; D distance: travel; C factor: compensation | Since 2.0.0, with MAGNETIC_PARKING_EXTRUDER: set its values, or report them without parameters |
M7219 | R row or C column: set it to the bits of V; X, Y index: set the LED there to V, or toggle it without V; D row with U unit: set a native row to V; I: clear; F: all on; P: print the state | With MAX7219_DEBUG: control MAX7219 LED matrices |
M993 to M999: flash, screen, update and restart
| Command | Parameters | Meaning |
|---|---|---|
M993 | None | With SPI flash, SD support and MARLIN_DEV_MODE: back up the flash to the card |
M994 | None | Restore that backup to the flash |
M995 | None | With TOUCH_SCREEN_CALIBRATION: open the calibration menu |
M997 | None documented | Since 2.0.0: start a firmware update from the card. Not on every platform; LPC176x, STM32 and STM32F1 restart into the bootloader |
M999 | S 0/1: resume without flushing the buffer | Run again after a stop, which also switched the heaters off. By default the serial buffer is flushed and the host asked to resend from the last N line |
Sources
- MarlinDocumentation – Marlin’s own documentation source, the files in
docs/gcode/for the commands on this page, as of 3 December 2026