我是用52写的,用两个595驱动4个数码管,程序哪不对了?include<reg51.h>
sbit SCK=P1^0;//数据输入时钟 11
sbit RCK=P1^1;//输出存储锁存时钟线12
sbit SI=P1^2;//数据线14
unsigned char code duan[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00};
unsigned char code wei[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
void _595in(unsigned char Data)
{
unsigned char k,m;
for(m=0;m<1;m++)
{
for(k=0;k<8;k++)
{
SCK=0;
if(Data&0x80)
SI=1;
else
SI=0;
Data<<=1;
SCK=1;
}
}
}
void delay2ms()
{
unsigned char i,j;
for(i=133;i>0;i--)
for(j=6;j>0;j--);
}
void _595out()
{
RCK=0;
// _nop_();
//delay2ms();
RCK=1;
}
void main()
{
unsigned char i;
while(1)
{
for(i=0;i<1;i++)
{
_595in(duan[i]);
_595out();
//_595in(wei[i]);
_595in(wei[i]);
_595out();
// delay2ms();
//_595in(duan[10]);
// delay2ms();
delay2ms();
}
}
}
此帖出自
小平头技术问答
一周热门 更多>