Electronics ru
Advanced Search +


Two PIC pins drive six LEDs

Benabadji Noureddine


This Design Idea (Figure 1) demonstrates a new method of driving six LEDs with only two I/O lines from a microcontroller, and so is particularly suitable for any pin-limited chip. It uses a pair of I/O lines combined with a pair of complementary bipolar transistors. More than one LED can appear to be lit by multiplexing [1-4] . A Some other Design Ideas use additional logic, which increases cost and size [5].

Two PIC pins drive six LEDs
Figure 1. Two PIC pins drive six LEDs

Note that VDD must be between 2V & 3V: for example, if LED2 is ON (Table 1), LED4 and LED6 will also light if VDD is too high. You can choose any general purpose low power transistors, but to keep the same brightness for each LED, choose transistors with low VCE(sat).

Table 1.  LED drive logic table. Avoid (0,0) and (1,1).


I/O lines

0 Z Z 0 0 0 0 0 0
1 1 0 1 0 0 0 0 0
2 0 1 0 1 0 0 0 0
3 1 Z 0 0 1 0 0 0
4 0 Z 0 0 0 1 0 0
5 Z 0 0 0 0 0 1 0
6 Z 1 0 0 0 0 0 1

For testing, a PIC10F200 and PIC10F322 was chosen as it is the smallest and simplest 6-pin microcontroller. For pedagogical purposes, the firmware has been provided as two separate and simple assembler sources:

  • dotmode1.asm acts as a free running dot chaser.
  • barmode1.asm displays an incremental bargraph.

Note that in either mode, only one LED is driven at a time, with a minimum amount of current (down to 2mA with high brightness LEDs), and uses periodic bursts of short pulses. The assembler sources are fully commented, optimized in size, and take less than 256 words, allowing the user to choose any other pin-limited PIC.


Source Codes (assembler) - download


  1. Increase efficiency in embedded digital-I/O lines
  2. A CharliePlexed RGB LED Dice
  3. One-chip 11×10 LED matrix.
  4. Eight-digit counter works with common anode or common cathode
  5. Microcontroller's Single I/O-Port Line Drives a Bar-Graph Display

You may have to register before you can post comments and get full access to forum.
User Name
Fragments of discussion:Full version of discussion »
  • An unusual application of the microcontroller. Thus, you can control relay through the optocoupler.

News on theme:

Slices ↓
Radiolocman facebook Radiolocman twitter Radiolocman google plus