# Interupt executing gcode and wait for a user click

**URL:** <https://klipper.discourse.group/t/interupt-executing-gcode-and-wait-for-a-user-click/13050>\
**Category:** General Discussion\
**Created:** [January 11, 2024, 10:13pm UTC](https://klipper.discourse.group/t/interupt-executing-gcode-and-wait-for-a-user-click/13050 "2024-01-11T22:13:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mk\_tom](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@mk\_tom](https://klipper.discourse.group/u/mk_tom)\
**Post date:** [January 11, 2024, 10:13pm UTC](https://klipper.discourse.group/t/interupt-executing-gcode-and-wait-for-a-user-click/13050/1 "2024-01-11T22:13:33Z")

</div>

### Basic Information:

Printer: BQ Witbox (nothing original)  
MCU: Arduino Mega 2560 + RAMPS 1.4

Hello folks,  
Is it possible to interrupt the further execution of the gCode until the user presses the rotary encoder?  
Analog M0 (Marlin). Useful for changing filament or somthing.

---

<div class="post-metadata">

**Author:** ![NAPCAL](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/napcal/32/1794_2.png) [@NAPCAL](https://klipper.discourse.group/u/NAPCAL)\
**Post date:** [January 11, 2024, 11:10pm UTC](https://klipper.discourse.group/t/interupt-executing-gcode-and-wait-for-a-user-click/13050/2 "2024-01-11T23:10:53Z")

</div>

I don’t know about the encoder button, but if you have PAUSE & RESUME macros, then just adding the word Pause in your Gcode file will execute the pause macro, and then via the web interface, you trigger the resume macro.

---

<div class="post-metadata">

**Author:** ![mk\_tom](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@mk\_tom](https://klipper.discourse.group/u/mk_tom)\
**Post date:** [January 12, 2024, 7:10pm UTC](https://klipper.discourse.group/t/interupt-executing-gcode-and-wait-for-a-user-click/13050/3 "2024-01-12T19:10:21Z")

</div>

PAUSE & RESUME: Yes, I know that. It’s simply more convenient to click on the encoder or on another connected switch. You don’t have to go back and forth.

Thank you

---

<div class="post-metadata">

**Author:** ![theophile](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/theophile/32/31_2.png) [@theophile](https://klipper.discourse.group/u/theophile)\
**Post date:** [January 12, 2024, 9:01pm UTC](https://klipper.discourse.group/t/interupt-executing-gcode-and-wait-for-a-user-click/13050/4 "2024-01-12T21:01:11Z")

</div>

You could easily configure a button to fire a custom gcode macro that would toggle between PAUSE and RESUME based on the current state of the machine.

---

<div class="post-metadata">

**Author:** ![mk\_tom](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@mk\_tom](https://klipper.discourse.group/u/mk_tom)\
**Post date:** [January 12, 2024, 9:52pm UTC](https://klipper.discourse.group/t/interupt-executing-gcode-and-wait-for-a-user-click/13050/5 "2024-01-12T21:52:22Z")

</div>

yes, but is then always active. Ideal would be within a certain macro. (Filament Change for example)  
THX

---

<div class="post-metadata">

**Author:** ![LifeOfBrian](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/lifeofbrian/32/2380_2.png) [@LifeOfBrian](https://klipper.discourse.group/u/LifeOfBrian)\
**Post date:** [January 12, 2024, 11:11pm UTC](https://klipper.discourse.group/t/interupt-executing-gcode-and-wait-for-a-user-click/13050/6 "2024-01-12T23:11:29Z")

</div>

You could save/evaluate a state with a global variable and only fire the button when it is the right time/macro

---

<div class="post-metadata">

**Author:** ![theophile](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/theophile/32/31_2.png) [@theophile](https://klipper.discourse.group/u/theophile)\
**Post date:** [January 13, 2024, 1:39am UTC](https://klipper.discourse.group/t/interupt-executing-gcode-and-wait-for-a-user-click/13050/7 "2024-01-13T01:39:55Z")

</div>

> [@mk\_tom](#):
>
> yes, but is then always active. Ideal would be within a certain macro. (Filament Change for example)

Macros can’t be interrupted like that. You’d have to split that macro into two with the first half running until the PAUSE, then the second half to continue after the RESUME.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/klipper/original/1X/64419bf2aac6639e6ef5cef200dcd456b0a01ac3.png) [@system](https://klipper.discourse.group/u/system)\
**Post date:** [March 13, 2024, 1:40am UTC](https://klipper.discourse.group/t/interupt-executing-gcode-and-wait-for-a-user-click/13050/8 "2024-03-13T01:40:48Z")

</div>

Closed on March 13, 2024, 1:40am UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
