Add as home page    Add to your favourites    Hello,Welcome! 【Login】 【Register】
LED Australia
                                                                         Your Position: Home > Articles > How to Light Multiple LEDs

How to Light Multiple LEDs

Monika / 2013-03-06
  1. Figure out how many pins will be needed to light the required number of LEDs. For the method described in this article, the equation to calculate the number of LEDs with so many pins available is: '#LEDs' = '#PINS' * ('#PINS' - 1)
  2. Attach a resistor, between 150 and 330 ohms depending on the LEDs, to each pin that is going to be used to light the diodes.
  3. Connect the anode of one LED to the cathode of the second LED and connect those two leads to one pin.
  4.  
  5. Then connect the cathode of the first LED to the anode of the second LED and connect them to the second pin.
     
  6. Repeat the process until every possible pair of pins has 2. Figure 1 illustrates how 3 pins would be used to light 6 LEDs. If an extra pin RB3 was to be added, there would be 6 extra LEDs: 2 between RB2 and RB3, 2 LEDs between RB1 and RB3 and 2 between RB0 and RB3.
    Figure 1: 6 LEDs with 3 pins
     
     
     
     
    Figure 1: 6 LEDs with 3 pins
     
  7. Program the micro-controller to turn on the desired LEDs. With this method only one LED can be on at a time. For an LED to light up, the pin connected to the anode has to be set to be an output and be high (5V), the pin connected to the cathode has to be set to output and be low (ground), and the rest of the pins connected to other LEDs have to be set to inputs. Figure 2 shows a table that explains how to light the individual LEDs shown in figure 1.
    Figure 2. Pin settings to control LEDs
     
     
     
     
    Figure 2. Pin settings to control LEDs
     
  8. Finally, set up a for loop to change the individual pin settings to switch between LEDs. If this for loop goes around fast enough, it will trick the human brain to think that all the LEDs are on at the same time. This is called multiplexing
LINK:
Home Company Profile Shipping & Freight info Payment Support Sitemaps

© 2005-2019 ALLED Copyright, All Rights Reserved.
Tel: 0285990000 E-mail: info@alled.com.au