---
tag: m0240
title: Trigger Camera
brief: Trigger a camera shutter
author: thinkyhead

requires: PHOTO_GCODE
group: extras

codes: [ M240 ]

notes:
  - "`CHDK_PIN` or `PHOTOGRAPH_PIN` is required prior to Marlin 2.0.0."
  - To use the `CHDK_PIN` or `PHOTOGRAPH_PIN` option with a digital camera see [this article](//www.doc-diy.net/photo/rc-1_hacked/).
  - To use an endstop or contact switch as a shutter switch for your smartphone's camera, see [this video](//youtu.be/i5g3ziK5wpI).

parameters:
  -
    tag: A
    optional: true
    description: Offset to the X return position. (Requires `PHOTO_POSITION`)
    values:
      -
        tag: offset
        type: float
  -
    tag: B
    optional: true
    description: Offset to the Y return position. (Requires `PHOTO_POSITION`)
    values:
      -
        tag: offset
        type: float
  -
    tag: D
    optional: true
    description: Duration to hold down the shutter switch. (Requires `PHOTO_SWITCH_POSITION` and `PHOTO_SWITCH_MS`)
    values:
      -
        tag: ms
        type: int
  -
    tag: F
    optional: true
    description: Feedrate for the main photo moves. If omitted, the homing feedrate will be used. (Requires `PHOTO_POSITION`)
    values:
      -
        tag: feedrate
        type: float
  -
    tag: I
    optional: true
    description: Shutter switch X position. If omitted, the photo move X position applies. (Requires `PHOTO_SWITCH_POSITION`)
    values:
      -
        tag: pos
        type: float
  -
    tag: J
    optional: true
    description: Shutter switch Y position. If omitted, the photo move Y position applies. (Requires `PHOTO_SWITCH_POSITION`)
    values:
      -
        tag: pos
        type: float
  -
    tag: P
    optional: true
    description: Delay after pressing the shutter switch. (Requires `PHOTO_SWITCH_POSITION` and `PHOTO_SWITCH_MS`)
    values:
      -
        tag: ms
        type: int
  -
    tag: R
    optional: true
    description: Retract/recover length. (Requires `PHOTO_POSITION`)
    values:
      -
        tag: length
        type: float
  -
    tag: S
    optional: true
    description: Retract/recover feedrate. (Requires `PHOTO_POSITION`)
    values:
      -
        tag: feedrate
        type: float
  -
    tag: X
    optional: true
    description: Main photo move X position. (Requires `PHOTO_POSITION`)
    values:
      -
        tag: pos
        type: float
  -
    tag: Y
    optional: true
    description: Main photo move Y position. (Requires `PHOTO_POSITION`)
    values:
      -
        tag: pos
        type: float
  -
    tag: Z
    optional: true
    description: Main photo move Z raise. (Requires `PHOTO_POSITION`)
    values:
      -
        tag: length
        type: float

videos:
  - i5g3ziK5wpI

examples:

---

Trigger a camera shutter using a digital pin or by bumping a physical switch.
