thinkyhead

M42 - Set Pin State

control Set an analog or digital pin to a specified state.

Description

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

Usage

M42 [I<bool>] [P<pin>] S<state> [T<0|1|2|3>]

Parameters

[I<bool>] 1.1.9.1

Ignore protection on pins that Marlin is using.

[P<pin>]

A digital pin number (even for analog pins) to write to. (LED_PIN if omitted)

S<state>

The state to set. PWM pins may be set from 0-255.

[T<0|1|2|3>] 2.0.5.2

Set the pin mode. Prior to Marlin 2.0.9.4 this is set with the M parameter.

  • T0:

    INPUT

  • T1:

    OUTPUT

  • T2:

    INPUT_PULLUP

  • T3:

    INPUT_PULLDOWN

Examples

Turn the LED pin on

M42 S1

Turn on pin 33

M42 P33 S1

Set pin 44 to do PWM with 50% DC

M42 P44 S128