求大神看看这是什么原因,还是不太会用这个模块儿
单片机源程序如下:
- #include<reg51.h>
- #include<intrins.h>
- sbit SRCLK=P1^2;
- sbit RCLK=P1^1;
- sbit SER=P1^0;
- unsigned char code Segduan[]={0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8,
- 0x80, 0x90, 0x88, 0x83, 0xc6, 0xa1, 0x86, 0x8e};
- unsigned char code Segwei[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
- void delay(unsigned int time)
- {
- unsigned int i,j;
- for(i=0;i<time;i++)
- for(j=0;j<121;j++);
- }
- void Hc595SendByte(unsigned char dat)
- {
- unsigned char a;
- for(a=0;a<8;a++)
- {
- SER=dat>>7;
- SRCLK=1;
- _nop_();
- _nop_();
- SRCLK=0;
- dat<<=1;
- }
- }
- void main()
- {
- unsigned int i;
- SRCLK=0;
- RCLK=0;
- while(1)
- {
- for(i=0;i<8;i++)
- {
- Hc595SendByte(Segwei[i]);
- Hc595SendByte(Segduan[i]);
- RCLK=1;
- _nop_();
- _nop_();
- RCLK=0;
- delay(100);
- }
- }
- }
复制代码 |