#include <16F887.h>
#use delay(clock=4M)
#fuses NOWDT ,HS ,NOPUT ,NOPROTECT ,NODEBUG , NOBROWNOUT , NOLVP , NOCPD //, NOWRT
//#use rs232(baud=9600,xmit=PIN_c6,rcv=PIN_c7) //
//#use i2c(Master,slow,sda=PIN_C4,scl=PIN_C3)// 100KHz
#use fast_io(b)
#use fast_io(d)
#define SCK PIN_C2 //shift register clock input
#define DAT PIN_C0 //serial data input
#define SCL PIN_C1 //storage register clock input
#define CONTROL PORTD
const char font[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
2,2,0xFE,2,2,0,0xFE,0x12,0x12,0x12,0xEC,0,0x7E,0x80,0x80,0xFE,0,0x7C,0x82,0x82,0x7C,0,0xFE,2
,2,0xFC,0,0x7C,0x82,0x92,0x74,0,0,0x10,0xFE,0x92,0x82,0x7C,0,0xF8,0x14,0x12,0x14,0xF8,0,0xFE,0,0
,0xFE,0x10,0x10,0xFE,0,0x7C,0x82,0x82,0x7C,0,0x7C,0x82,0x82 ,0x44 ,0 ,0 ,0xFE ,0x8A ,0x8A ,0x74 ,0 ,0xF8 ,0x14 ,0x12
,0x14 ,0xF8 ,0 ,0x7C ,0x82 ,0x82 ,0x44 ,0 ,0xFE ,0x10 ,0x10 ,0xFE ,0 ,0 ,0xFE ,0x28 ,0x44 ,0x82 ,0 ,0xFE ,0x10 ,0x10 ,0xFE ,0
,0x7C ,0x82 ,0x82 ,0x7C ,0 ,0xF8 ,0x14 ,0x12 ,0x14 ,0xF8 ,0 ,0 ,2 ,2 ,0xFE ,2 ,2 ,0 ,0xFE ,0x12 ,0x12 ,0x12 ,0x0C ,0x80
,0xFE ,0x10 ,0x10 ,0xFE ,0 ,0x7C ,0x82 ,0x82 ,0x44 ,0 ,0xFE ,4 ,8 ,4 ,0xFE ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0};
const char hang[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
int8 i=0,j=0,a,b;
void led595()
{
for(b=0;b<=4;b++){
for(i=0;i<=7;i++)
{
for(j=0;j<=31;j++) //dua 32 bit o vi tri thu i cua moi byte vao
{
if (bit_test(font[a+j],i)) output_high(DAT);
else output_low(DAT);
output_high(PIN_C2);
output_low(PIN_C2); //bo sung them gia tri dieu kien
}
output_d(hang);
output_high(PIN_C1);
output_low(PIN_C1);
delay_ms(2);
}
}
}
void main()
{
output_high(PIN_C1);
output_high(PIN_C2);
set_tris_c(0xff);
set_tris_d(0x00);
while(1)
{
a=0;
for(a=0;a<=140;a++)
{
led595();
}
}
}