Program for multiplexing of led displays for pic microcontrollers

Program for multiplexing of led displays for pic microcontrollers

Suppose you want to design the ac digital voltmeter rang up to 0-300v or above, by using any pic 8-bit mcu, and want to use 3, 7-segment display for it then there can be a problem as to how do you indicate such large value on display

then you can go with the following approch

use BCD to 7 segment converter, so that only 4 bits can be used to control a single 7 seven segment display..... so in total u need 12 output lines. you can get 12 output bits by using 2 different ports of any suitable 8 bit microcontroller. link to one such converter http://www.ee.washington.edu/stores/DataSheets/74ls/74ls47.pdf

use 7 bits from one port for all 3 displays and use 3 other bits to select led's this is done very fast so human eye can not make out that the displays are glowing sequencially and not continously.

here is sample code for pic

#include

#include

void DisplayNumber( unsigned int number );

void main()

{

trisb = 0;

trisa = 0xFF;

unsigned int randNumb = 0;

while( 1 )

{

while( porta.0 == 0 ) // wait for key pressed

DisplayNumber( randNumb ); // display number to keep display refreshed

// while key pressed increment counter

// Number will be random based on how long input is turned on

while( porta.0 == 1 )

{

randNumb++;

if( ++randNumb > 9999 )

randNumb = 0;

}

// display a series of random numbers so it looks like we are

char j;

for( j = 0; j < x =' rand();' i =' 0;' i =' 0x01;' i =' 0b1000;'>>= 1 )

{

digit = number % 10;

number /= 10;

portb = digit & 0x0F;

portb = (digit & 0x0F)

Related articles

How To to build an ISP for Atmega 128
LED blinking program for Pic microcontroller
Program to initialise the LCD in 4 bit mode using PIC microcontroller
PWM with 89S52
A microprocessor Program to convert BCD pack and Unpack number for 8085.


For best business class hosting read InMotion Reviews and get a good web hosting deal.