Intro: Self-Correcting Polarity Protection
Accidentally mismatching positive and negative while hooking up a circuit is often a fatal blow to delicate electronics. Even if you absentmindedly pop in a battery the wrong way or forget to pay attention to the polarity of the power supply connector once, microcontrollers may die, LED's will fail to illuminate, motors will spin backwards, and capacitors may catch fire.
To protect their circuits from a perilous reverse-polarity situation, many builders include a diode (conducts electricity in only one direction) in series with their circuit to stop backwards current from doing any damage. But the problem with this approach is that the circuit won't work until you correct the reverse-polarity, which is sometimes not possible without adjusting connectors or finding a correctly-polarized wall wart.
To add flexibility to your circuit and allow it to function with any polarity DC current, consider adding the above circuit to your project. You no longer have to worry about making a backwards connection or finding an AC wall adapter that has a center-positive connector or whatever.
This circuit uses a bridge rectifier normally used in AC-powered equipment to direct the incoming current appropriately so that it comes out correctly on the pins labeled "+" and "-". Simply connect your power supply (don't worry about the polarity) to the pins marked AC (or "~" or "in"), wire your circuit to "+" and "-", and enjoy the flexibility and protection. You can buy a complete bridge rectifier in a single case, or you can make it out of four diodes. Note the orientation of the diodes (the white bands) in the picture; they must be arranged as shown.
One downside of this trick is that the output voltage will be one or more volts lower than the input (depending on the diodes' voltage drop). -Just keep that in mind. Be sure to use diodes that are rated for high current, rectifier use.