# Issue with external interrupt

**URL:** <https://forums.openmv.io/t/issue-with-external-interrupt/577>\
**Category:** OpenMV Boards\
**Created:** [February 14, 2018, 11:58pm UTC](https://forums.openmv.io/t/issue-with-external-interrupt/577 "2018-02-14T23:58:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebastian](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@sebastian](https://forums.openmv.io/u/sebastian)\
**Post date:** [February 14, 2018, 11:58pm UTC](https://forums.openmv.io/t/issue-with-external-interrupt/577/1 "2018-02-14T23:58:41Z")

</div>

Hi,

I’m attempting to trigger a snapshot every time the camera receives a TTL pulse. I keep getting the same error which I believe is related to pin allocation:

> ValueError: ExtInt vector 14 is already in use

. Below is my code.

```python
import sensor, image, time
from pyb import Pin, ExtInt

sensor.reset()                   
sensor.set_pixformat(sensor.RGB565) 
sensor.set_framesize(sensor.QVGA)   
sensor.skip_frames(time = 2000)    
clock = time.clock()                
syncFlag = 0

def callback (line):
    syncFlag = 1
    
while(True):
    ext = ExtInt(Pin('P0'), ExtInt.IRQ_RISING, Pin.PULL_UP, callback)
    if (syncFlag == 1):
        img=image.snapshot()
        syncFlag = 0

```

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [February 15, 2018, 12:59am UTC](https://forums.openmv.io/t/issue-with-external-interrupt/577/2 "2018-02-15T00:59:46Z")

</div>

Don’t create the interrupt in the loop. Make it outside of the loop.
