Em có cái mạch như sau:
Đây là code:
#include <16f877a.h>
#fuses nowdt,noprotect, nolvp, xt,put
#use delay(clock=4000000)
#use fast_io(a)
#use fast_io(b)
#byte portb=0x06
#bit RA0=0X05.0
#bit CLK=0X05.1
#bit STR=0X05.2
int ABCD[32]={0x03,0x01,0xCC,0xCC,0x01,0x03,0xFF,0xFF,0x00,0x0 0,0x66,0x66,0x00,0x99,0xFF,0xFF,0x81,0x00,0x3C,0x3 C,0x18,0x99,0xFF,0xFF,0x00,0x00,0x3C,0x3C,0x81,0xC 3,0xFF,0xFF};
int b1[32]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,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};
int b2[32]={255,255,255,255,255,255,255,255,0x7f,0xbf,0xdf,0 xef,0xf7,0xfb,0xfd,0xfe,255,255,255,255,255,255,25 5,255,255,255,255,255,255,255,255,255};
int b3[32]={255,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,255,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd ,0xfe,255,255,255,255,255,255,255,255};
int b4[32]={255,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,255,255,255,0x 7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
signed int j,x,i,dem;
void truyen(int byte_1,int byte_2, int byte_3,int byte_4);
void hienchu_hot(int a);
void hienchu();
void kieu();
void main()
{
set_tris_b(0);
set_tris_a(0);
while(1)
{
for(x=-31;x<32;x++)
{dem=20;
while(dem>0)
{
hienchu_hot(x);
dem--;
}
}
}
}
void hienchu_hot(int a)
{ j=0;
for(i=a;i<a+32&i<32;i++)
{ if(i>=0)
{
truyen(b1[i],b2[i],b3[i],b4[i]);
portb=ABCD[j];
delay_us(500);}
j++;
}
}
void truyen(int byte_1,int byte_2,int byte_3,int byte_4)
{
int i,Q;
Q=byte_4; for(i=0;i<8;i++) { RA0=Q&0x01;CLK=0; CLK=1;Q>>=1;}
Q=byte_3; for(i=0;i<8;i++) { RA0=Q&0x01;CLK=0; CLK=1;Q>>=1;}
Q=byte_2; for(i=0;i<8;i++) { RA0=Q&0x01;CLK=0; CLK=1;Q>>=1;}
Q=byte_1; for(i=0;i<8;i++) { RA0=Q&0x01;CLK=0; CLK=1;Q>>=1;}
STR=0;
STR=1;
}
Các ae cho mình hỏi:
- Tại sao lúc mới chạy thì chữ hiện ra nhanh nhưng từ từ lại chậm lại
- Bây h chữ chạy là từ phải sang, nhưng mình muốn chỉnh nó chạy từ trái sang, hoặc chỉ hiện chữ mà không chạy thì làm sao ạh.
Đây là code:
#include <16f877a.h>
#fuses nowdt,noprotect, nolvp, xt,put
#use delay(clock=4000000)
#use fast_io(a)
#use fast_io(b)
#byte portb=0x06
#bit RA0=0X05.0
#bit CLK=0X05.1
#bit STR=0X05.2
int ABCD[32]={0x03,0x01,0xCC,0xCC,0x01,0x03,0xFF,0xFF,0x00,0x0 0,0x66,0x66,0x00,0x99,0xFF,0xFF,0x81,0x00,0x3C,0x3 C,0x18,0x99,0xFF,0xFF,0x00,0x00,0x3C,0x3C,0x81,0xC 3,0xFF,0xFF};
int b1[32]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,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};
int b2[32]={255,255,255,255,255,255,255,255,0x7f,0xbf,0xdf,0 xef,0xf7,0xfb,0xfd,0xfe,255,255,255,255,255,255,25 5,255,255,255,255,255,255,255,255,255};
int b3[32]={255,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,255,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd ,0xfe,255,255,255,255,255,255,255,255};
int b4[32]={255,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,255,255,255,0x 7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
signed int j,x,i,dem;
void truyen(int byte_1,int byte_2, int byte_3,int byte_4);
void hienchu_hot(int a);
void hienchu();
void kieu();
void main()
{
set_tris_b(0);
set_tris_a(0);
while(1)
{
for(x=-31;x<32;x++)
{dem=20;
while(dem>0)
{
hienchu_hot(x);
dem--;
}
}
}
}
void hienchu_hot(int a)
{ j=0;
for(i=a;i<a+32&i<32;i++)
{ if(i>=0)
{
truyen(b1[i],b2[i],b3[i],b4[i]);
portb=ABCD[j];
delay_us(500);}
j++;
}
}
void truyen(int byte_1,int byte_2,int byte_3,int byte_4)
{
int i,Q;
Q=byte_4; for(i=0;i<8;i++) { RA0=Q&0x01;CLK=0; CLK=1;Q>>=1;}
Q=byte_3; for(i=0;i<8;i++) { RA0=Q&0x01;CLK=0; CLK=1;Q>>=1;}
Q=byte_2; for(i=0;i<8;i++) { RA0=Q&0x01;CLK=0; CLK=1;Q>>=1;}
Q=byte_1; for(i=0;i<8;i++) { RA0=Q&0x01;CLK=0; CLK=1;Q>>=1;}
STR=0;
STR=1;
}
Các ae cho mình hỏi:
- Tại sao lúc mới chạy thì chữ hiện ra nhanh nhưng từ từ lại chậm lại
- Bây h chữ chạy là từ phải sang, nhưng mình muốn chỉnh nó chạy từ trái sang, hoặc chỉ hiện chữ mà không chạy thì làm sao ạh.