麻烦各位进来看下,谢谢了
测试开关K0,当K0开关开置ON时,6个数码管同时亮“8“,当开关拨置OFF时,6个数码管同时灭,同时亮地交替进行。我自己写的代码如下,请问有问题么??谢谢啦!!
#include<reg51.h>
void melay(unsigned int t)
{
unsigned int i;
for(i = 0; i < t; i++);
}
sbit P_1 = P1^0;
sbit P_2 = P1^1;
sbit P_3 = P1^2;
sbit P_4 = P1^3;
sbit P_5 = P1^4;
sbit P_6 = P1^5;
void main()
{
while(1)
{
if(P_1 = 1)
{
P_1;
melay(20000);
P_2;
melay(20000);
P_3;
melay(20000);
P_4;
melay(20000);
P_5;
melay(20000);
P_6;
melay(20000);
}
if(P_1 = 0)
{
P_1 = 1;
for( ; ; )
{
P_1 != P_1;
melay(20000);
P_2 != P_2;
melay(20000);
P_3 != P_3;
melay(20000);
P_4 != P_4;
melay(20000);
P_5 != P_5;
melay(20000);
P_6 != P_6;
melay(20000);
}
}
}