是按键检测,写的太烂不好意思全部写上来,
我的积分为0也给不出分啊,
#include <stdio.h>
#include <reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char
uchar x,y,z;
//uchar code table[]={0x01,0x02};
int num,num1,s1num;
sbit sw1=P0^0;
sbit sw2=P0^1;
sbit sw3=P0^2;
sbit sw4=P0^3;
sbit out1=P1^0;
sbit out2=P1^1;
sbit out3=P1^2;
void delay(uint z);
void init();
void main()
{
num=0x01;
P1=0x07;
P0=0x00;
while(1)
{
if(sw1==1)
{
delay(5);
while(sw1);
P1=0x00;
s11:
if(sw3==1)
{
delay(5);
if(sw3==1)
{
while(sw3);
num--;
if(num==0);
num=1;
}
}
if(sw4==1)
{
delay(5);
if(sw4==1)
{
while(sw4);
num++;
if(num==5);
num=4;
}
}
if(sw2==1)
{
delay(5);
while(sw2);
goto s10;
}
goto s11;
s10:
if(num==1)
{
out1=1;
out2=1;
out3=1;
}
if(num==2)
{
out1=1;
}
if(num==3)
{
out2=1;
}
if(num==4)
{
out3=1;
}
//
if(num==5)
//
{
//
break;
//
}
}
}
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}