I just posted some code here: https://github.com/hydronics2/Bee-counter-3.1/tree/master
yes, I think a gap sensor would work great. I went with the reflective sensors because I thought at the time they were less expensive and then became interested in mfg with surface mount parts.
I added a zip file with eagle docs next to the schematics.
sorry I don't really have a good sketch to publish right now. I'll try to get it on github soon.
the gates are 3/8 wide (9.5mm) and the headers are 8.5mm high. I've not completed the testing and finish the programming to distinguish between drones and workers but I think it should be pretty easy to do.
Acrylic flowers of SMD LEDs