30-8-3.c

来自「C51程序应用例子,自己的学习历程,希望可以帮到大家」· C语言 代码 · 共 49 行

C
49
字号
#define uint unsigned int
#define uchar unsigned char
#define ulong unsigned long
#include<reg52.h>

sbit P10=P1^0;
sbit P11=P1^1;
sbit P12=P1^2;
sbit P13=P1^3;

bit ldelay=0;

void main(void)
{
uchar code ledp[4]={0xfe,0xfd,0xfb,0xf7};
uchar ledi;

RCAP2H=0x10;
RCAP2L=0x00;

TR2=1;
ET2=1;
EA=1;

while(1)
{
if(ldelay)
{
ldelay=0;
P10=ledp[ledi];
ledi++;
if(ledi==4)ledi=0;
}
}
}

timer0() interrupt 5
{
static uchar t;
TF2=0;
t++;
if(t==30)
{
t=0;
ldelay=1;
}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?