This web site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more.

Picmicro and Led displays

Last update: 31/07/2015

A quick way to show a result or to display a data is represented by the connection of a digit display directly to the port of a microcontroller. Such device can be very quickly and easily connected to any picmicro provided by a couple of ports. In our case we'll use an 'old' pic16F84 or a newer pic16F628.

As we can see the four digits are connected to the same port (PORTB) and are switched on/off by the first four pins of the PORTA. Switching on, quickly, only one display at the time we can see the correct result according to the permanence of an image on the retina of the eye.

display led picmicro  

Transistors: Any small NPN
Resistor: 2.2K to 10K on the base of the transistor; 330ohm between the port pins and the display.

int x,y,l;

char numbers[16]={0x3F, 0x06, 0x5B,           // Chars 0-9 A-F array
0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F,
0x6F, 0x77, 0x7C, 0x39, 0x5E, 0x79, 0x71};
char cn[4] = {1,2,4,8};                                      // = bits 0b0001  0010  0100  1000 of  PORTA

void main()
TRISA = 0;
TRISB = 0;
CMCON = 7;                                                    // only 16F628 to disable comparators. To be removed if pic=16F84
PORTA = 0;
// --------------------First loop                             simple slow loop to show all chars
for (x=0;x<4;x++)
{  PORTA = cn[x];
    for (y=0; y<16; y++)     
         {  PORTB = numbers[y];
            delay_ms(150);   } 
 } delay_ms(1000);

// --------------------Second loop                        same loop faster

for (x=0;x<4;x++)
{PORTA = cn[x];
  for (y=0; y<16; y++)     
   {  PORTB = numbers[y];
      delay_ms(15); }

//--------------------Third loop                            same loop very fast repeated 255 times

{     for (x=0;x<4;x++)    
      { PORTA = cn[x];      
        for (y=0; y<16; y++)      
        {PORTB = numbers[y];         
          delay_us(100); } 

This is simple program (Mikroc) useful to check the integrity of the connections between the picmicro and the four led displays.

The first array is used to store the characters (0-9 A-F) while a second array is used to set properly the PORTA (to switch on a single digit).

A loop is repeated at different speeds three times where we can see (at higher speed) that all four display look switched on at the same time. The loop, in fact, must be repeated 256 times to be readable.

Schematic to download available in the repository



Diritti riservati 2008-2015. Tutti i marchi riportati sono detenuti dai legittimi proprietari. Tutto il materiale e` liberamente utilizzabile ma non per scopi commerciali. Non si assume alcuna responsabilita` sul materiale pubblicato per eventuali danni diretti o indiretti che possano derivare dall`utilizzo di schemi, progetti o altro materiale presente nel sito. Inviare una mail a: (contenuti) (webserver) per domande e/o suggerimenti.