For my project I try to create a finger tracking solution, where IR leds attached to a Plexi-screen highlights the finger and the position is tracked by the camera. In our first solution we used a webcam for this purpose: (https://www.youtube.com/watch?v=y_BVaneZLIw). in the next iteration we would like to us openMV, and first tests already look promising, but the IR Leds get very hot if we keep them running continuously.

So I thought it would be a good idea to sync them with the image capture frequency, but while it is clear to me how to control an IO pin to drive a relay or a transistor, its not clear how my python code should look like in order to make this work. My naive idea in pseudo code: