<p>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:</p>

<pre><code>#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 \
}
</code></pre>

<p>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.</p>

CC BY-SA 3.0
2017-05-15T14:22:11.360Z
2017-08-14T05:08:03.497Z
2017-08-14T05:08:03.497Z
markshancock
<p>Might be because servo pins are not connected to 5V. use Jumper as shown</p>

<p><a href="https://i.sstatic.net/ycegg.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ycegg.png" alt="enter image description here"></a></p>

CC BY-SA 4.0
2019-01-31T18:24:58.803Z
Does this affect the ability to drive the GPIO? I don't need a 5V power supply, just a TTL signal.
nanofarad
CC BY-SA 4.0
2019-01-31T18:44:45.343Z
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
CC BY-SA 4.0
2019-01-31T18:54:02.013Z
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
CC BY-SA 4.0
2019-01-31T18:59:34.320Z
May be that pin is already used by firmware for some other purpose like servos are enabled
Athul
CC BY-SA 4.0
2019-01-31T16:38:57.877Z
2019-01-31T16:38:57.877Z
Athul
<p>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:</p>

<pre><code>M42 P4 S255
</code></pre>

<p>according to the pinout in the following image:</p>

<p><a href="https://i.sstatic.net/TRInv.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/TRInv.png" alt="enter image description here"></a></p>

<p>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?</p>

CC BY-SA 4.0
2018-10-14T23:19:30.210Z
@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
CC BY-SA 4.0
2018-10-14T23:22:20.007Z
Maybe not then, in that case. Thanks for the update. I'm not sure what to do in this situation... it seems like it will be forever uncertain whether it worked or not. Not to worry :-)
Greenonline
CC BY-SA 3.0
2017-01-13T23:14:51.847Z
Post your firmware settings. Also verify your source for the board. If it is a cheap knockoff board...
MakerModder
CC BY-SA 3.0
2017-01-15T02:08:07.453Z
@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
CC BY-SA 3.0
2017-06-01T02:30:53.270Z
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
<marlin><ramps-1.4>
Why am I not seeing an effect from an M42 command on Marlin?
nanofarad
# Why am I not seeing an effect from an M42 command on Marlin?

(Asked by: username_0 on 2017-01-12)

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:

[![enter image description here](https://i.sstatic.net/TRInv.png)](https://i.sstatic.net/TRInv.png)

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?

**Tags:** marlin, ramps-1.4

> **Comments:**
> **username_2**: Post your firmware settings. Also verify your source for the board. If it is a cheap knockoff board...  
> **username_0**: @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`.  
> **username_3**: I'd try M42 P4 S0 just in case it's somehow inverted. If so, then and only then I'd worry about why.  
> **username_0**: @username_1 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?  
> **username_1**: Maybe not then, in that case. Thanks for the update. I'm not sure what to do in this situation... it seems like it will be forever uncertain whether it worked or not. Not to worry :-)  

---

## 2 answers

### Answer by username_4 on 2017-05-15. Score: 5

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.


---

### Answer by username_5 on 2019-01-31. Score: 1

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

[![enter image description here](https://i.sstatic.net/ycegg.png)](https://i.sstatic.net/ycegg.png)

> **Comments:**
> **username_0**: Does this affect the ability to drive the GPIO? I don't need a 5V power supply, just a TTL signal.  
> **username_5**: 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.  
> **username_0**: 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.  
> **username_5**: May be that pin is already used by firmware for some other purpose like servos are enabled  

---

