welove8051
Full Member level 6
Code:
#include <HTC.H>
__CONFIG(XT & WDTDIS & PWRTDIS & BORDIS & LVPDIS & WRTEN );
unsigned char a,b,i,seg[11]={192,249,164,176,153,146,130,248,128,144,127};
void init()
{
TRISB=0;
PORTB=128;
i=0;
}
void main()
{
init();
while(1)
{
for(i=0;seg[i]!='\0';i++)
{
b=seg[i];
a=~b;
PORTB=a;
_delay(100000);
_delay(100000);
_delay(100000);
_delay(100000);
_delay(100000);
}
while(1);
}
}
this code is used to display 0 to 9 and dot in 7 seg.
my doubt is how we detect a end of array or a string using null character and how to use it in the for loop.
for(i=0;seg!='\0';i++)
regards
kj