📄 2008.c
字号:
#include<regx52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
uint DAT[]={0xc0,0xf9,0xa4,0xb0,
0x99,0x92,0x82,0xf8,
0x80,0x90,0x88,0x83,
0xc6,0xa1,0x86,0x8e,0xff};
uint CH[]={0xfe,0xfd,0xfb,0xf7};
sbit DS1=P1^5;
sbit ST1=P1^4;
sbit SH1=P1^3;
sbit DS0=P1^2;
sbit ST0=P1^1;
sbit SH0=P1^0;
uchar temp0,temp1;
void delay(void)
{
uchar i,j;
for(i=10;i>0;i--)
for(j=248;j>0;j--);
}
/*位选*/
void WR0(void)
{
uchar j;
for(j=0;j<8;j++)
{
temp0=temp0<<1;
DS0=CY;
SH0=1;
_nop_();
_nop_();
SH0=0;
}
}
void OUT0(void)
{
ST0=0;
_nop_();
_nop_();
ST0=1;
_nop_();
_nop_();
_nop_();
ST0=0;
}
/*位显*/
void WR1(void)
{
uchar j;
for(j=0;j<8;j++)
{
temp1=temp1<<1;
DS1=CY;
SH1=1;
_nop_();
_nop_();
SH1=0;
}
}
void OUT1(void)
{
ST1=0;
_nop_();
_nop_();
ST1=1;
_nop_();
_nop_();
_nop_();
ST1=0;
}
main()
{
ST0=0;
SH0=1;
ST1=0;
SH1=1;
while(1)
{
temp1=DAT[2];
WR1();
OUT1();
temp0=0x07;
WR0();
OUT0();
delay();
temp1=DAT[0];
WR1();
OUT1();
temp0=0x0b;
WR0();
OUT0();
delay();
temp1=DAT[0];
WR1();
OUT1();
temp0=0x0d;
WR0();
OUT0();
delay();
temp1=DAT[8];
WR1();
OUT1();
temp0=0x0e;
WR0();
OUT0();
delay();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -