#include <reg51.h>
sbit K1 = P0^0;
sbit led1 = P2^0;
sbit led2 = P2^1;
sbit led3 = P2^2;
sbit led4 = P2^3;
sbit led5 = P2^4;
sbit led6 = P2^5;
sbit led7 = P2^6;
sbit led8 = P2^7;
void delayms(unsigned char ms) // 延时子程序
{
unsigned char i;
while(ms--)
{
for(i = 0; i < 120; i++);
}
}
main()
unsigned char cishu;
while(1)
{
cishu++;
if K1==0
{
if cishu==1
{led1==0;}
else if cishu==2
{led2==0;}
else if cishu==3
{led3==0;}
else if cishu==4
{led4==0;}
else if cishu==5
{led5==0;}
else if cishu==6
{led6==0;}
else if cishu==7
{led7==0;}
else if cishu==8
{led8==0;}
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>