programming problem in 7segment display
hi every one..
i'm facing some problem in my projects. i worked it on proteus and i have attached some snaps shot of my project. i'm reading analog i/p from RA2 and display it on 4 7-segments devices. i used 74ls78 bcd to 7 segment decoder and 74ls138 decoder. i've copied my source code too with this. the fig1 shows the intial setup and fig2 shows the during execution of the project. i think the problem with the code it self.. when i simulate in proteus only one device is active and its always shows zero (0) irrespective of analog input. i want to display the result on 7 segment so please go through the code and let me know if is there any changes have to make in this.
code:
#include<16f877.h>
unsigned int cnt, brk;
char led [3];
unsigned int rem;
void converter (unsigned int z);
void scanled (void);
void main()
{
OPTION_REG=0x80;
PORTA=0;
TRISA=255;
PORTD=0;
TRISD=0;
while(1)
{
cnt=ADC_Read(2);
cnt=cnt*5;
converter (cnt);
scanled ();
}
}
void converter(unsigned int z)
{
led[0]=z/1000;
rem=z%1000;
led[1]=rem/100;
rem=rem%100;
led[2]=rem/10;
led[3]=rem%10;
}
void scanled (void)
{
unsigned char i;
for (i=0;i<4;i++)
{
portd=i;portd=led[i];delay_ms(10);
}
}
Bookmarks