Còn đây là code: e dùng CSS
#include <16f877a.h>
//#include <def_877a.h>
#FUSES NOWDT, HS, NOPUT, NOPROTECT, NODEBUG,NOBROWNOUT, NOLVP, NOCPD, NOWRT
#use fast_io(b)
#use fast_io(d)
#use delay(clock=20000000)
int32 send_reg;
int16 m,l,x,lap,s;
int32 const chay[]={0x80000000,0x40000000,0x20000000,0x10000000,
0x08000000,0x04000000,0x02000000,0x01000000,0x0080 0000,0x00400000,0x00200000,0x00100000,0x00080000,0 x00040000,0x00020000,0x00010000,
0x00008000,0x00004000,0x00002000,0x00001000,0x0000 0800,0x00000400,0x00000200 ,0x00000100,
0x00000080,0x00000040,0x00000020,0x00000010,0x0000 0008,0x00000004,0x00000002,0x00000001,0x00000000};
const unsigned char data[]={
255,255,255,255,255,255,255,255,255,255,255,255,25 5,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,25 5,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,25 5,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,25 5,255,255,255,
0,0,231,231,0,0,255,255,252,252,0,0,252,252,255,25 5,
255,49,32,44,12,140,255,255,255,192,128,63,63,128, 192,255,255,1,0,252,252,0,1,255,
255,255,255,255,255,255,255,255,255,255,255,255,25 5,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,25 5,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,25 5,255,255,255
};
#bit d7=send_reg.0
void serout(){
int8 n;
for(n=0;n<=32;n++)
{
output_low(pin_b0);
if(d7!=0)
output_high(pin_b0);
output_low(pin_b1);
output_high(pin_b1);
send_reg=send_reg >>1;
}
}
void display(){
output_high(pin_b2);
serout();
output_low(pin_b3);
output_high(pin_b3);
}
void hc595(){
m=32;
x=0;
for(x=0;x<=32;x++){
output_d(data[l+m]);
send_reg=chay[x];
display();
m--;
}
}
void main(){
set_tris_d(0);
output_d(255);
set_tris_b(0x00);
while(true){
l=0;
for(l=0;l<=100;l++){
for(s=0;s<=1;s++)
{
for(lap=0;lap<=5;lap++){
hc595();
}
}
}
}
}
Xin AE chỉ giúp là mạch có sai chỗ nào ko mà nó chạy loạn xạ?
File proteus: Quét 4 Led Matrix = PIC 16F877A + IC 74HC595 Chạy từ phải sang trái.rar
