/* LED CHAY TU TRAI SANG PHAI VA NGUOC LAI*/
#include <16f887.h>
#use delay(clock=20000000)
#FUSES HS,nowdt
#BYTE PORTD=0X08
#define RD0 PIN_b0 
#define RD1 PIN_B1 
#define RD2 PIN_B2 
#define RD3 PIN_B3 
#define RD4 PIN_B4 
#define RD5 PIN_B5 
#define RD5 PIN_B6
#define RD5 PIN_B7
void main() 
{
  int16 k,t,p,i;
  set_tris_d(0);
   while(1)
   {
   output_a(0xFF);
   output_high(0x00);
   delay_ms(300);
   output_low(0xFF);
   delay_ms(300);
   for(k=0x01; k<0x100; k=k<<1){output_B(k);delay_ms(200);}
   for(k=0x100;k>0;k>>=1){output_B(k);delay_ms(200);}
   for(i=0x80,p=0x2,t=0x100;p>0;p>>=1){output_a(p|t); delay_ms(400);t<<=1;}
   }

}
