An officer's pulling over a driver constitutes a detention—the driver hasn't been arrested, but nevertheless isn't free to leave. Where a typical detention is concerned, officers must have reasonable suspicion that the detainee is committing or has committed a crime. But since roadblocks and sobriety checkpoints are, generally speaking, legal, one might wonder whether officers can generally stop drivers on a whim. The answer is no.
In Delaware v. Prouse, the Supreme Court considered the case of man prosecuted for marijuana possession. (440 U.S. 648 (1979).) In the course of a traffic stop, the police officer had seen marijuana on the defendant's car floor.
The officer testified that he hadn't seen the defendant's vehicle violate any traffic laws before he conducted the detention. He hadn't observed any equipment violations, nor had he witnessed any suspicious activity. He enforced the stop only so that he could check the driver's license and the vehicle's registration. He wasn't acting in accordance with any established guidelines or procedures. The Court held that his kind of "spot check," left entirely to the police officer's discretion, is unconstitutional.
BAD STOPS DON'T ALWAYS MEAN BAD EVIDENCE
The exclusionary rule generally requires that evidence that results from an unlawful detention or arrest be excluded from court. But not always.
Suppose a warrant is out for your arrest. An officer who's unaware of the warrant detains you, but not because you were doing anything wrong. Maybe the officer is speculating that you're up to no good. Whatever the reason, it's not reason enough: The policeperson doesn't have reasonable suspicion that you have committed or are committing a crime.
The officer asks for your identification, has dispatch run a check, and learns about the warrant. The cop arrests and searches you, finding some kind of contraband in your pockets.
Even though the stop was illegal because it wasn't based on reasonable suspicion, the contraband could very well be admissible against you in court. The U.S. Supreme Court has held, essentially, that arrest warrants can retroactively justify illegal detentions. (For much more on the rules in this area, see this article on the "attenuation doctrine.")
For information on challenging an illegal detention or search, see What is a motion to suppress?