Light emitting diodes work like normal diodes and so are only conducting in one direction. Current only flows from the positive terminal to the negative terminal.
Identifying + and -
Round LEDs with legs have a short and a long leg when new. The longer leg is the positive leg (anode), the short leg is the negative (cathode). Other LEDs usually have marks which can be found in their data sheets. If the legs of an LED are already cut often there's still a flattened part on the LED's marking the negative side.
what happens if the polarity is reversed?
In reverse direction usually no current will flow. Too much voltage in reverse direction however will cause a current to flow. The voltage where this happens is called the breakdown voltage as this is where the usually isolating junction inside the LED is breaking down and becomes conductive. The current flowing in reverse direction is called the reverse current and possibly dangerous for an LED (the allowed reverse current is often much lower than the allowed forward current). Also the LED will emit no light when reverse current is flowing. Don't be worried when experimenting with voltages around 5V like Arduino's outputs, but take care when using external power supplies with higher voltages.
Resistor calculation for an LED
In a series circuit an LED "eats" voltage. No matter what current flows through the LED - the voltage it uses remains almost the same. For example a single red LED will always eat 1.4V - no matter if 1mA or 20mA flow through it.
To calculate a resistor value for one LED three things have to be known:
- the supply voltage
- the voltage the LED eats
- the desired current through the LED.
Let's assume we have 5V for supply and an LED which eats 1.4 V. So if we subtract the 1.4 V from the 5 V supply there remain 3.6 V which aren't eaten by the LED. So a resistor has to use the remaining voltage at the desired current. We want our LED to use 15 mA. So the resistor can be calculated: R = U/I which is in this case: R = 3.6V / 0.015 A = 240 ohms.
Connecting an LED to AC voltage
As described above reverse current may destroy an LED - so it is a good idea to let the reverse current flow around the LED with an additional diode or a second LED which is connected in parallel to the LED but in opposite direction.
Unknown voltage of an LED
There are different methods of determining the voltage of an LED. If the wave length is known the minimum voltage to create light can be calculated
http://www.pveducation.org/pvcdrom/properties-of-sunlight/energy-of-photon (or LED color chart)
If the wave length is unknown the LED can be connected to an adjustable voltage source via a large resistor and the voltage can be gradually increased until a small current flows through the LED (for example 1mA will be ok for most LEDs without destroying them). Then the voltage of the LED can be measured (in parallel to the LED).