@kwagyeman : Fantastic - that’s clear, thanks.
So I think - I got it to work. Although this might no be the most elegant way - any suggestion(s) are welcome
Picking up on some the code that was already posted in this forum:
Essentially what I am trying to achieve is - External event → trigger pulse → turn on illumination/acquire → turn off illumination → next pulse → repeat
Tested the code using a 1Hz trigger pulse connected to input pin7 and a small led connected to the output pin0 → the triggered output image stream shows a static lit led ( no flickering or intensity fluctuation from one image to the next ). Not sure if I am capturing on the THE trigger pulse or the the following one though. I don’t have a spare probe to check the timing between P0/P7.
import sensor, image, time, pyb
from pyb import Pin, ExtInt
sensor.skip_frames(time = 2000)
# sensor acquisition trigger when calling snapshot()
# Create a clock object to track the FPS.
clock = time.clock()
# set ext. trigger input pulse
sync = 0
def syncline (line):
sync = 1
ext = ExtInt(Pin('P7'), ExtInt.IRQ_RISING, Pin.PULL_DOWN, syncline)
# set illumination source pin objects
pin0 = Pin('P0', Pin.OUT_PP, Pin.PULL_NONE)
pin7 = Pin('P7', Pin.IN)
if (sync == 1):
clock.tick() # Update the FPS clock.
pin0.value(pin7.value()) # turn on illumination source
img = sensor.snapshot()
pin0.low() # turn off illumination source
sync = 0