GPIO tricks

There are a number of tricks that can be used to drive multiple LEDs when you are short of GPIO pins on your micro-controller. Read on …

One switch or GPIO / multiple LEDs

1 GPIO, 2 LEDs A single GPIO pin can be used to light two LEDs. How it works When the output is switched low current will flow from the positive supply via R1 and the L1, green, to the output pin. L1 will illuminate. L2, red, will be shorted out and will be dark. When the … Continue reading "One switch or GPIO / multiple LEDs"
A single GPIO pin alternating the two LEDs of a common cathode dual LED.

1 GPIO, bi-colour LED, common cathode

Driving a bi-colour LED with one pin is possible! When GPIO  pins are in short supply a dual red-green common-cathode LED can still be used with the addition of a PNP transistor and base resistor. How it works When the GPIO pin is high L1, green, is turned on. There is no bias current for … Continue reading "1 GPIO, bi-colour LED, common cathode"
GPIO and bi-colour 2-pin LED.

1 GPIO, bi-colour, 2-pin LED

Driving a bi-colour, 2-pin LED with one pin is possible! When GPIO pins are in short supply a bi-colour 2-pin LED may seem like a good idea. It can be done, but is not that efficient. How it works When GPIO is low R1 provides current to L2 and the indicator glows red. When GPIO is … Continue reading "1 GPIO, bi-colour, 2-pin LED"
2 x GPIO, bi-colour LED-1

2 GPIO, 1 bi-colour 2-pin LED

If two GPIO pins are available controlling a 2-pin bi-colour back-to-back LED is simple. How it works To light L1, green, switch GPIO1 high and GPIO2 low. Current will flow from left to right. To light L2, red, switch CPIO2 high and GPIO1 low. Current will flow from right to left. To cross-fade or mix colours toggle between … Continue reading "2 GPIO, 1 bi-colour 2-pin LED"
Simplified logic output.

High-side versus low-side switching

Most micro-controllers and logic families have output stages which can connect the output to the positive supply or to ground. This allows the micro to put a definite ‘high’ (+5 V in this example) onto the output or a definite ‘low’ (ground) rather than let it float which could cause problems if the output is feeding … Continue reading "High-side versus low-side switching"
Please link to us if you find the information helpful ...<br>Tweet about this on Twitter
Twitter
Share on Facebook
Facebook
Pin on Pinterest
Pinterest
Digg this
Digg
Share on LinkedIn
Linkedin
Share on Reddit
Reddit
Share on StumbleUpon
StumbleUpon
Share on Tumblr
Tumblr