Triggering a PiCamera when the M6E Nano reads a tag

Good Morning,

First, thank you for your assistance on my previous question. I found it helpful and now I can interface successfully my RPi with the M6E Nano.

With that said, I now want to trigger the Pi Camera connected to the RPi whenever the reader reads a tag. I know this can be done modifying the python code provided and adding an If statement somewhere in the code. My logic is the following:

I want the the reader to continuosly read, non-stop. Then…

If “the reader reads a tag”:

camera.start_recording()

If “camera is recording”

disable the previous if statement so the camera doesnt start recording again. Begin a timer of 5 seconds.

If “the reader doesn’t read a tag in 5 seconds”

camera.stop_recording()

enable the first if statement again.

And then, every time I record, I want the video to be saved with a different name (ie. vid1, vid2, vid3, etc). I may need to create some kind of for loop for this.

I would like some insight on how this could be done.

Thank you so much for your help. I appreciate it.

Unfortunately we SparkFun help you write the code to do this, but other forum users may be able to assist.