<p>Apparently, given one </p>

<ul>
<li>has already enabled <code>USE_&lt;AXIS&gt;_PLUG</code> (for example 
<code>&lt;AXIS&gt; = XMIN</code>) in Marlin's <code>Configuration.h</code>,</li>
<li>one can add an additional <code>define</code> (for example <code>&lt;AXIS&gt;_ENDSTOP_CUSTOM</code>) in
<code>Configuration.h</code> and </li>
<li>make this <a href="https://github.com/MarlinFirmware/Marlin/blob/0110faa717e642574ade9eb7aed250ee2840e942/Marlin/endstops.cpp#L637" rel="nofollow noreferrer">block</a> the <code>else</code> statement in an
<code>&lt;AXIS&gt;_ENDSTOP_CUSTOM</code> existence check, with the positive case being your
arbitrary task.</li>
</ul>

<p>The function that gets executed in the standard case in the linked block is <code>PROCESS_ENDSTOP</code>, so cloning it would be a good starting point to make a <code>PROCESS_ENDSTOP_CUSTOM</code> task, too.</p>

CC BY-SA 4.0
2019-09-24T14:17:17.817Z
Interesting - presumably you could then execute both the current endstop task (stop moving, indicate zero, etc) and some new tasks (launch cruise missiles, start playing Fast& Furious on the large-screen monitor).
Carl Witthoft
CC BY-SA 4.0
2019-09-23T13:58:13.963Z
2019-09-23T13:58:13.963Z
Scrooge McDuck
<p>Can someone point me out an appropriate entry code for this task in Marlin source code?</p>

<marlin><endstop>
Reprogram Marlin to assign endstop pins to arbitrary tasks [Arduino Mega]
Scrooge McDuck
# Reprogram Marlin to assign endstop pins to arbitrary tasks [Arduino Mega]

(Asked by: username_0 on 2019-09-23)

Can someone point me out an appropriate entry code for this task in Marlin source code?

**Tags:** marlin, endstop

---

## 1 answers

### Answer by username_0 on 2019-09-23. Score: 2

Apparently, given one

* has already enabled `USE__PLUG` (for example
   `= XMIN`) in Marlin's `Configuration.h`,
* one can add an additional `define` (for example `_ENDSTOP_CUSTOM`) in
  `Configuration.h` and
* make this [block](https://github.com/MarlinFirmware/Marlin/blob/0110faa717e642574ade9eb7aed250ee2840e942/Marlin/endstops.cpp#L637) the `else` statement in an
  `_ENDSTOP_CUSTOM` existence check, with the positive case being your
  arbitrary task.

The function that gets executed in the standard case in the linked block is `PROCESS_ENDSTOP`, so cloning it would be a good starting point to make a `PROCESS_ENDSTOP_CUSTOM` task, too.

> **Comments:**
> **username_1**: Interesting - presumably you could then execute both the current endstop task (stop moving, indicate zero, etc) and some new tasks (launch cruise missiles, start playing Fast& Furious on the large-screen monitor).  

---

