1.功能描述
五个灯点击依次亮
2.程序
A.#include <REGX51.H>
#define uchar unsigned char
sbit SW=P1^0;
void main()
{
TMOD=0x20;
TH1=0xfa;
TL1=0xfa;
SCON=0x50;
PCON=0x00;
TR1=1;
while(1)
{
SBUF=P1;
while(!TI);
TI=0;
}
}
B.#include <REGX51.H>
#define uchar unsigned char
sbit LED=P1^0;
void main()
{
TMOD=0x20;
TH1=0xfa;
TL1=0xfa;
SCON=0x50;
PCON=0x00;
TR1=1;
while(1)
{
while(!RI);
P1=SBUF;
RI=0;
}
}
3.电路图
4.流程图
5.小结
没啥大问题