#include<htc.h>
int _XTAL_FREQ=12000000;
int i;
void forv();
void rev();
void reva();
void fora();
void DelayMs(unsigned char delay)
{
unsigned int j;
for(i=0;i<=delay;i++)
{
for(j=0;j<=1000;j++);
}
}
void port_initialize()
{
TRISB=0X00;
PORTB=0x00;
TRISC=0xFF;
#define a RC0
#define b RC1
#define c RC2
#define d RC3
}
void main()
{
port_initialize();
while(1)
{
if(a>0x00)
{
forv();
}
if(b>0x00)
{
rev();
}
if(c>0x00)
{
reva();
}
if(d>0x00)
{
hfora();
}
}
}
void forv()
{
PORTB=0x05;
DelayMs(50);
PORTB=0x09;
DelayMs(50);
PORTB=0x0A;
DelayMs(50);
PORTB=0x06;
DelayMs(50);
}
void rev()
{
PORTB=0x08;
DelayMs(100);
PORTB=0x09;
DelayMs(100);
PORTB=0x01;
DelayMs(100);
PORTB=0x03;
DelayMs(100);
PORTB=0x02;
DelayMs(100);
PORTB=0x06;
DelayMs(100);
PORTB=0x04;
DelayMs(100);
PORTB=0x0C;
DelayMs(100);
}
void reva()
{
PORTB=0x05;
DelayMs(150);
PORTB=0x09;
DelayMs(150);
PORTB=0x0A;
DelayMs(150);
PORTB=0x06;
DelayMs(150);
}
void fora()
{
PORTB=0x05;
DelayMs(200);
PORTB=0x09;
DelayMs(200);
PORTB=0x0A;
DelayMs(200);
PORTB=0x06;
DelayMs(200);
}