📄 shuma.c
字号:
/**************************************************/
/*用定时器以间隔1S在6位共阴极数码管上依次显示0---F*/
/*大学生电子设计论坛 http://www.nuedc.net.cn */
/*作者:杨sir 版权没有 欢迎使用 */
/*在线技术支持QQ:68723936 */
/**************************************************/
#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit wx=P2^3;
sbit dx=P2^4;
uchar code table[]={0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
uchar code table2[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf};
uchar t,num,temp,num2;
void main()
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
temp=0xfe;
while(1)
{
if (t==20)
{
t=0;
wx=1;
/*P0=table2[num2];
num2++;
if (num2==6) num2=0;*/ //可以查表也可以用左移
P0=temp;
temp=_crol_(temp,1);
if (temp==0xbf) temp=0xfe;
wx=0;
dx=1;
P0=table[num];
dx=0;
num++;
if (num==16) num=0;
}
}
}
void timer0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
t++;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -