#include<reg52.h>
sbit SH_CP=P2^0;
sbit DS=P2^1;
sbit ST_CP=P2^2;
unsigned char code display[]={
};
void hc595_senddat(unsigned char dat)
{
unsigned char i;
for(i=0;i<8;i++)
{
DS=dat&0x80;
SH_CP=1;
SH_CP=0;
dat<<=1;
}
}
main()
{
unsigned char i,n;
unsigned int k,m;
char j;
m=sizeof(display);
SH_CP=0;
ST_CP=0;
while(1)
{
for(k=0;k<m;k=k+2)
for(n=0;n<2;n++)
for(i=0;i<16;i++)
{
for(j=3;j>=0;j--)
{
hc595_senddat(display[(32*j+2*i+1+k)%m]);
hc595_senddat(display[(32*j+2*i+k)%m]);
}
P3=i;
ST_CP=1;
ST_CP=0;
}
}
}
这是我的程序,还请大神修改!感谢
|