Hi all!
I have written some code that blocks the program from starting until a BNC input is received so that I can time the beginning of port availability with a fiber photometry recording. I also wanted to do this so that it would work as a "timeout" until the session starts. Before receiving BNC input, the FED3 is unresponsive. However, a poke will be counted in a given port if it is poked during this "timeout" period. Once a BNC input is received, it acts as if the poke occurred immediately. (active port poked during timeout --> BNC input --> conditioned stimulus immediately occurs, pellet is delivered, and count is updated). I haven't been able to write code that stops this from happening, so wanted to see if I could gain some insight here! Considering this seems specific to the port being activated (if I only hit the inactive port, it will only run the inactive port code) and is sequential (if I hit the inactive and then the active, it will run the inactive code --> active code and count both pokes), I think it might have to do with a value on the corresponding pins that is being carried over between this "timeout" period to the actual session. Any help would be greatly appreciated! Attached below will be the edited pieces that are required to run this. I updated the sketch, the .h, and .cpp files so all will be needed in the right places to run the program.
Thanks,
Eric Mitten
** If any one is interested in using this code, there are a couple of extra tweaks I've added. (1) This code turns on a "house light" for the duration of the session and turns them off at session end. (2) It also blocks the program from counting pokes following session end. (3) I have included a "Time of Event" column in the datasheet that allows me to sync up FED3 events with times during the fiber photometry recording to look at Ca2+ dynamics. It calculates the time by comparing the timing of events in relation to the time BNC input was received, so this is integral to this column. (4) There is a startup screen that displays "waiting for BNC input" and an end menu screen that displays "session has ended!." I'm currently writing code to allow for an internal reset 5 minutes after session end so that I don't have to manually reset after each run.