flexi-bot/docs/marlin/_gcode/M042.md
2023-09-05 20:38:49 +02:00

1.4 KiB

tag title brief author requires group codes notes parameters examples
m0042 Set Pin State Set an analog or digital pin to a specified state. thinkyhead DIRECT_PIN_CONTROL control
M42
tag optional since description values
I true 1.1.9.1 Ignore protection on pins that Marlin is using.
type
bool
tag optional since description values
T true 2.0.5.2 Set the pin mode. Prior to Marlin 2.0.9.4 this is set with the `M` parameter.
tag description
0 `INPUT`
tag description
1 `OUTPUT`
tag description
2 `INPUT_PULLUP`
tag description
3 `INPUT_PULLDOWN`
tag optional description values
P true A digital pin number (even for analog pins) to write to. (`LED_PIN` if omitted)
tag type
pin int
tag optional description values
S false The state to set. PWM pins may be set from 0-255.
tag type
state int
pre code
Turn the LED pin on M42 S1
pre code
Turn on pin 33 M42 P33 S1
pre code
Set pin 44 to do PWM with 50% DC M42 P44 S128

For custom hardware not officially supported in Marlin, you can often just connect up an unused pin and use M42 to control it.