Saturday 19 September 2015

LED Blinking and Chaser using 2 switches in PIC

#include<pic.h>
void DELAY();
void main()
{
int i;
TRISB=0X00;                          // PORT B as output 
TRISC=0XFF;                         //  PORT C as input
while(1)
{
if(RC0==1)                             // RC0 input for led blinking
{
PORTB=0XFF;
DELAY();
PORTB=0X00;
DELAY();
}
else if(RC1==1)                      // RC1 input for chaser
{
PORTB=0X01;
DELAY();
for(i=0;i<8;i++)
{
PORTB=PORTB<<1;
DELAY();
}
}
}
}
void DELAY()
{
int i,j;
for(i=0;i<100;i++)
for(j=0;j<100;j++);
}

No comments:

Post a Comment