湖南软件职业学院吧 关注:92,778贴子:3,200,271
  • 3回复贴,共1
#include<reg51.h>
sbit s1=P3^0;
sbit s2=P3^1;
sbit s3=P3^2;
sbit s4=P3^3;
unsigned char val=4;
void delay(unsigned int x)
{
unsigned int i,j;
for(i=x;i>0;i--)
for(j=114;j>0;j--);
}
void scan()
{
P3=0x0f;
if((P3&0x0f)!=0x0f)
delay(10);
if(s1==0)
{
val=0;
while(s1==0);
delay(10);
while(s1==0);
}
if(s2==0)
{
val=1;
while(s2==0);
delay(10);
while(s2==0);
}
if(s3==0)
{
val=2;
while(s3==0);
delay(10);
while(s3==0);
}
if(s4==0)
{
val=3;
while(s4==0);
delay(10);
while(s4==0);
}
}
void main()
{
P1=0x00;
while(1)
{
scan();
switch(val)
{
case 0:
P1=0xff;
delay(500);
P1=0x00;
delay(500);
break;
case 1:
P1=0x55;
delay(300);
P1=0xaa;
delay(300);
break;
case 2:
P1=0x0f;
delay(200);
P1=0xf0;
delay(200);
break;
case 3:
P1=0x00;
break;
default:break;
}
}
}


1楼2016-10-12 19:36回复
    666


    IP属地:湖南来自Android客户端2楼2016-10-12 19:38
    回复
      欢迎前来复制粘贴


      IP属地:湖南来自Android客户端3楼2016-10-12 19:39
      回复