<blockquote>
<p>The standard G code of &quot;wait one second&quot; is G04 X1 on many CNC machines. Does this code exists on 3D printers as well?</p>
</blockquote>
<p><strong>Yes.</strong> The exact set of commands supported by a given printer will depend on the firmware, so you should check the documentation for the particular printer you're looking at. But the <code>G04</code> &quot;Dwell&quot; command is a common one. A list of all the G-code commands for the Marlin firmware, which is widely used, can be found at <a href="https://marlinfw.org/meta/gcode/" rel="nofollow noreferrer">https://marlinfw.org/meta/gcode/</a>.</p>
<blockquote>
<p>Is it possible to extract a trigger signal (e.g. 5V) from the 3D printer? Are printers available which provide a G code for an external trigger?</p>
</blockquote>
<p>Marlin supports an <code>M240</code> command that means &quot;trigger camera,&quot; which could probably be used to trigger other sorts of devices too. See: <a href="https://marlinfw.org/docs/gcode/M240.html" rel="nofollow noreferrer">https://marlinfw.org/docs/gcode/M240.html</a> You might also want to look into using OctoPrint to control your printer; there's a plugin (OctoLapse) for making time-lapse photos that might prove useful.</p>

CC BY-SA 4.0
2021-03-29T20:53:10.610Z
2021-03-29T20:53:10.610Z
Caleb
<p><a href="https://marlinfw.org/docs/gcode/G004.html" rel="nofollow noreferrer">G4</a> is the &quot;Dwell&quot; command in Marlin, so you could specify a wait duration using it. Note that the time parameter is designated using S for seconds and/or P for milliseconds:</p>
<pre><code>G4 S1    ; Wait for 1 second
</code></pre>
<p>I think you could use the <a href="https://marlinfw.org/docs/gcode/M043-T.html" rel="nofollow noreferrer">M43 T code</a> to set a pin high/low and act as a trigger signal. This would be coded for and not something that is done as a result of something detected, however:</p>
<pre><code>M43 T S3 R1 W1000    ; Toggle pin 3 once and then wait for a second
</code></pre>

CC BY-SA 4.0
2021-03-29T20:44:33.303Z
2021-03-29T20:44:33.303Z
Rykara
<p>I'd like to buy a 3D printer and use it as a &quot;platform&quot; for an <strong>external</strong> optical sensor. The idea is to mount an optical sensor on the Z-axis and to put a workpiece on the X-Y table.  Now, I'd like to move the sensor across the workpiece and trigger the measurement of the optical sensor. Hence, the 3D printer is not actually printing, but only used as a motion and trigger device for the optical sensors.</p>
<p>I have never used a 3D printer, but I'm afraid that I'll run into several problems:</p>
<ol>
<li>The standard G-code of &quot;wait one second&quot; is <code>G04 X1</code> on many CNC machines. Does this code exist on 3D printers as well?</li>
<li>Is it possible to extract a trigger signal (e.g. 5 V) from the 3D printer? Are printers available which provide a G-code for an external trigger? Could anybody suggest a model? I'm happy to pay some extra dollars if I don't have to solder by myself. Of course, a second option would be to use the voltage, which is used to heat the filament.</li>
</ol>

<g-code><linear-motion>
Use external sensor
NotMe
# Use external sensor

(Asked by: username_0 on 2021-03-29)

I'd like to buy a 3D printer and use it as a "platform" for an **external** optical sensor. The idea is to mount an optical sensor on the Z-axis and to put a workpiece on the X-Y table. Now, I'd like to move the sensor across the workpiece and trigger the measurement of the optical sensor. Hence, the 3D printer is not actually printing, but only used as a motion and trigger device for the optical sensors.

I have never used a 3D printer, but I'm afraid that I'll run into several problems:

1. The standard G-code of "wait one second" is `G04 X1` on many CNC machines. Does this code exist on 3D printers as well?
2. Is it possible to extract a trigger signal (e.g. 5 V) from the 3D printer? Are printers available which provide a G-code for an external trigger? Could anybody suggest a model? I'm happy to pay some extra dollars if I don't have to solder by myself. Of course, a second option would be to use the voltage, which is used to heat the filament.

**Tags:** g-code, linear-motion


---

## 2 answers

### Answer by username_1 on 2021-03-29. Score: 3

> The standard G code of "wait one second" is G04 X1 on many CNC machines. Does this code exists on 3D printers as well?

**Yes.** The exact set of commands supported by a given printer will depend on the firmware, so you should check the documentation for the particular printer you're looking at. But the `G04` "Dwell" command is a common one. A list of all the G-code commands for the Marlin firmware, which is widely used, can be found at <https://marlinfw.org/meta/gcode/>.

> Is it possible to extract a trigger signal (e.g. 5V) from the 3D printer? Are printers available which provide a G code for an external trigger?

Marlin supports an `M240` command that means "trigger camera," which could probably be used to trigger other sorts of devices too. See: <https://marlinfw.org/docs/gcode/M240.html> You might also want to look into using OctoPrint to control your printer; there's a plugin (OctoLapse) for making time-lapse photos that might prove useful.


---

### Answer by username_2 on 2021-03-29. Score: 3

[G4](https://marlinfw.org/docs/gcode/G004.html) is the "Dwell" command in Marlin, so you could specify a wait duration using it. Note that the time parameter is designated using S for seconds and/or P for milliseconds:

```
G4 S1    ; Wait for 1 second

```

I think you could use the [M43 T code](https://marlinfw.org/docs/gcode/M043-T.html) to set a pin high/low and act as a trigger signal. This would be coded for and not something that is done as a result of something detected, however:

```
M43 T S3 R1 W1000    ; Toggle pin 3 once and then wait for a second

```


---

