Bacterial motility is associated to a wide range of biological processes and it plays a key role in the virulence of many pathogens. Here we describe a method to distinguish the dynamic properties of bacteria by analyzing the statistical functions derived from the trajectories of a bacterium trapped by a single optical beam. The approach is based on the model of the rotation of a solid optically trapped sphere. The technique is easily implemented in a biological laboratory, since with only a small number of optical and electronic components a simple biological microscope can be converted into the required analyzer. To illustrate the functionality of this method, we probed several Salmonella enterica serovar Typhimurium mutants that differed from the wild-type with respect to their swimming patterns. In a further application, the motility dynamics of the S. Typhimurium cheV mutant were characterized.