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>] [M<0|1|2|3>] [P<pin>] S<state>

Parameters

[I<bool>]

Ignore protection on pins that Marlin is using.

[M<0|1|2|3>]

Set the pin mode.

  • M0:

    INPUT

  • M1:

    OUTPUT

  • M2:

    INPUT_PULLUP

  • M3:

    INPUT_PULLDOWN

[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.

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