C program to turn on/off, 8 LED lights in sequence, using PIC 16f877a microcontroller
Program:
#include
<htc.h>
//device
configuration bit
__CONFIG(0x3F3A);
delay();
void
main()
{
TRISC=0;
unsigned int a,i;
while(1)
{
a=1;
for(i=0;i<8;i++)
{
PORTC=a;
a=a<<1;
a=a+1;
delay();
}
for(i=0;i<8;i++)
{
a=a>>1;
PORTC=a;
delay();
}
}
}
delay()
{
unsigned int j;
for(j=0;j<=50000;j++);
}
Proteus Simulated design:
< click on the image for enlarged view >