程序如下:
#include<reg52.h>
sbit ser=P2^0;
sbit OE=P2^1;
sbit rck=P2^2;
sbit sck=P2^3;
unsigned char code duan[10]={0x3f,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char code wei[8]={0xfe,0xfd,0xfb,0xf7,
0xef,0xdf,0xbf,0x7f};
void delay(unsigned char i);
void delay2ms(void)
{
unsigned char i,j;
for(i=100;i>0;i--)
for(j=6;j>0;j--);
}
void in_wei(unsigned char Data)
{
unsigned char i;
for(i=0;i<8;i++)
{
sck=0;
ser=Data&0x80;
Data<<=1;
sck=1;
}
}
void in_duan(unsigned char Data)
{
unsigned char i;
for(i=0;i<8;i++)
{
sck=0;
ser=Data&0x80;
Data<<=1;
sck=1;
}
}
void out()
{
rck=0;
rck=1;
}
void main()
{
unsigned char i=0;
OE=0;
while(1)
{
rck=0;
in_wei(wei[i]);
in_duan(duan[i]);
out();
delay2ms();
i++;
if(i>7)
i=0;
}
}
void delay(unsigned char i)
{
while(--i);
}
该
电路采用的是2个595控制的8位共阴数码管,这样编程应该是动态显示,但为什么不能实现,求指点???、
该怎么修改???
out 函数是一个输出函数,相当于给595芯片12引脚存储器时钟脉冲rck 一个上升沿,这样就能够并行输出。
一周热门 更多>