A Light Emitting Diode (LED) can be connected in either way as shown the the following diagrams:
For Current Source configuration, the LED output is sourcing current so it flowing out of the microcontroller output. In this case, the LED is connected between the GND and the microcontroller output pin. This means that the LED will be switched ON when the microcontroller output is HIGH and switched OFF when the microcontroller output is LOW. This is as shown below, D13 is represented by a pin on the microcontroller.
For a Current Sink Configuration shown below, the LED output is sinking current since it is flowing into the microcontroller output. Tn this case, the LED is connected between the positive supply and the microcontroller output. This means that the LED will be switched ON when the microcontroller output is LOW, and will be switched OFF when the microcontroller output is HIGH.
To determine the value of the current limiting resistor to use, the formula bellow is used:
Where Vcc is the supply voltage; Vf is the LED forward voltage and I is the LED forward current. Vf and I are given in the datasheet of the LED. Therefore, if a supply voltage of 5V is to be used and Vf=1.5V; I = 10mA, the current limiting resistor to be connected will be given by