http://www.engadget.com/2011/02/01/m...omatic-weapon/
Built by a non-gunner for his uncle, counts your shots to tell you how many rounds you have left in the mag, video-game style.
I don't think the electronics to build this are that complex, the accelerometer chip inside is also used for autopilot on R/C aircraft.
H.