Using microcontrollers for optimal counting of single-photon events | Synapse