📄 less2-1a.c
字号:
#include<reg51.h>
#include <INTRINS.H>
#define uint unsigned int
#define uchar unsigned char
//#define nop() _nop_();_nop_();
void delay(uint);
sbit ds=P1^4;
sbit shcp=P1^5;
sbit stcp=P1^6;
sbit oe=P1^7;
uchar code tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xbf,0xff};//0-9,-,全灭
void sendbyte(uchar byte)
{
uchar num,c;
num=tab[byte];
for(c=0;c<8;c++) // 一位一位的发送数据
{
shcp=0;
ds=num&0x80;
num=num<<1;
shcp=1;
}
}
void out595(void)
{
stcp=0;
delay(10);
stcp=1;
oe=0;
}
void display(uchar word) //显示十位和个位
{
uchar i,j;
i=word/10; //十位
j=word-10*i; //个位
sendbyte(j);
sendbyte(i);
out595();
}
main()
{
while(1)
{
uchar n;
for(n=0;n<100;n++) //显示0到99
{
display(n);
out595();
delay(600);
}
}
}
void delay(uint z)
{
uint x,y;
for(x=100;x>0;x--)
for(y=z;y>0;y--);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -