LEDs

Compare the two ways to connect an LED to the microcontroller for digital output shown at the right. In the first, the chip acts as the source of current for the LED. Putting the pin high (digital 1) puts 5 volts at the anode of the LED. Since the cathode is grounded, the LED illuminates.

In the second, the anode of the LED is always at 5V, and the cathode is wired to the pin. Placing 5V (digital 1) at the pin means there is 5V at the anode and the cathode. Since the difference is 0V, the LED is off. Taking the pin low (digital 0) places the pin at 0 volts and allows it to sink current. Electricity can now flow through the LED and it illuminates.

Why bother? Typically a microcontroller can sink more current than it can source. A BX24 can only source 15 mA of current on any one pin, but it can sink 20. An LED hooked up in the "reverse" manner will be much brighter, since 33% more current passes through it.