# Why am I not seeing an effect from an M42 command on Marlin?

I'm trying to use one of the RAMPS GPIOs to control an external device that requires a 5V low-current logic level signal from Marlin. In order to do this programmatically, my host software (Octoprint) is sending an M42 command. I am using the following syntax:

M42 P4 S255


according to the pinout in the following image:

However, the pin appears to not be driven to a logic HIGH level. Is there firmware-level configuration I need to do as well, or is my syntax/pin number incorrect?

• Post your firmware settings. Also verify your source for the board. If it is a cheap knockoff board... – StarWind0 Jan 13 '17 at 23:14
• @StarWind I'll follow up with the printer vendor regarding board source. There are no configuration elements specific to pins or GPIOs that I see in Configuration.h or Configuration_adv.h. – nanofarad Jan 15 '17 at 2:08
• I'd try M42 P4 S0 just in case it's somehow inverted. If so, then and only then I'd worry about why. – Ecnerwal Jun 1 '17 at 2:30
• Did Mark's answer help at all. If so, please could you mark it as accepted. If it didn;t and you have resolved your issue, could you post an answer and accept that, please. As a beta site we need to keep our unanswered question list to a minimum. Thanks – Greenonline Oct 14 '18 at 23:14
• @Greenonline Unfortunately, the printer is no longer in my possession (I no longer work in that lab and am in a different city hours away altogether), and the issue was worked around by somebody else in a manner unknown to me. Mark's answer does seem sensible but I can't confirm that it works--shall I select it regardless? – nanofarad Oct 14 '18 at 23:19

I looked at the current Marlin code and the P24 command should work as you expect it unless the pin you are trying to use in listed as the "SENSITIVE_PINS" list:

#define SENSITIVE_PINS { 0, 1, \
X_STEP_PIN, X_DIR_PIN, X_ENABLE_PIN, X_MIN_PIN, X_MAX_PIN, \
Y_STEP_PIN, Y_DIR_PIN, Y_ENABLE_PIN, Y_MIN_PIN, Y_MAX_PIN, \
Z_STEP_PIN, Z_DIR_PIN, Z_ENABLE_PIN, Z_MIN_PIN, Z_MAX_PIN, Z_MIN_PROBE_PIN, \
PS_ON_PIN, HEATER_BED_PIN, FAN_PIN, FAN1_PIN, FAN2_PIN, CONTROLLER_FAN_PIN, \
_E0_PINS _E1_PINS _E2_PINS _E3_PINS _E4_PINS BED_PINS \
_H0_PINS _H1_PINS _H2_PINS _H3_PINS _H4_PINS \
_X2_PINS _Y2_PINS _Z2_PINS \
X_MS1_PIN, X_MS2_PIN, Y_MS1_PIN, Y_MS2_PIN, Z_MS1_PIN, Z_MS2_PIN \
}


These pins are printer specific; so, without access to your Marlin build, I can't see if pin 4 corresponds to one of these. If this is the problem, the command should be returning an error. If there is no error, I would look closely at the hardware.

Might be because servo pins are not connected to 5V. use Jumper as shown

• Does this affect the ability to drive the GPIO? I don't need a 5V power supply, just a TTL signal. – nanofarad Jan 31 '19 at 18:24
• I cannot say for sure. Tomorrow I will check on my board. If you want to check the working of M42 using marlin, send 'M42 S255 since no pin number is given, by default LED_PIN(pin number 13, RAMPS LED is attached to this pin.) pin will turn ON. You can send M42 P20 S255` and get gpio output from 20th pin (In your image I2C section pin 20 or 21). I have checked this. it works. – Athul Jan 31 '19 at 18:44
• It's not a strong concern regardless; I haven't had access to the printer in question for a number of years now (since I graduated/moved), but I suspect that because the atmega2560 drives the pins from its internal supply, setting that jumper would power the fixed 5V pin but not affect the IO/signal pin. – nanofarad Jan 31 '19 at 18:54
• May be that pin is already used by firmware for some other purpose like servos are enabled – Athul Jan 31 '19 at 18:59