Ok. Everything has been assembled and mounted. I mounted the control unit inside the stock. Power comes from the gun battery. The wires from the photo interrupter to the control unit run inside the handguard and upper receiver. I have drilled through the aluminium endblocks of the handguard and I'm using three pin RC servo type plugs and sockets to connect the silencer with the IR photo transistor and LED to the gun (I need to unplug it in order to unscrew it) and also inside the stock so I can easily disassemble the gun.
And it works pretty darn good, actually!
I actually ended up using a separate IR LED (this one) and photo transistor (this one) instead of a "fork" type photointerrupter. They are mounted by drilling a 3 mm hole in the styrofoam inside an old silencer and glueing them in place. It was easier than trying to get the photo interrupter to fit.
One thing I might want to change should I decide to do a version 2 is to replace the 7 segment read-out with a LED bar instead (like this one here). Because I don't so much need to know the exact number of remaining rounds – rather, I need a quick indication of full, half empty and nearly empty. And it could easily be made with a LED bar graph. Especially it it was multi-colored. And if it was wired in a common-cathode configuration it could be driven with the same hardware since the MAX7219 LED driver can control individual LEDs as well as 7 segment displays.
And to those who have asked: sorry, I won't be making any kits. But you are welcome to use the design and code for your own projects.
Here are some pictures:
And here are the final Eagle files for the board and a partlist (for most of the parts – resistors, capacitors etc. – the exact part is not important and should be considered an example part only):
Airsoft rounds counter SMD
Thank you for the details :) Sad you wont be reselling but Happy it works well. So was your revised post your final board? and any chance of a part's list :) I'd be ordering from Digi key in canada, so some of those parts are hard to find the exact one you used.
Congrats on the awesome project. and thanks again for sharing!