LEDs
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.
|