该楼层疑似违规已被系统折叠隐藏此楼查看此楼
#include"reg52.h"
#define uint unsigned int
#define uchar unsigned char
sbit k1=P3^4;
sbit k2=P3^5;
sbit k3=P3^6;
void delay(uint xms)
{
uint i,j;
for(i=xms;i>0;i--)
for(j=110;j>0;j--);
}
void main()
{
uchar kaishi=0;
k1=1;
k2=1;
k3=1;
while(1)
{
if(k1==0)
{
delay(10);
if(k1==0)
kaishi=1;
while(!k1);
}
if(k3==0)
{
delay(10);
if(k3==0)
kaishi=2;
while(!k3);
}
if(k2==0)
{
delay(10);
if(k2==0)
kaishi=0;
while(!k2);
}
if(kaishi==1)
{
P1=0xfe;
delay(500);
P1=0xfc;
delay(500);
P1=0xfd;
delay(500);
P1=0xf9;
delay(500);
P1=0xfb;
delay(500);
P1=0xf3;
delay(500);
P1=0xf7;
delay(500);
P1=0xf6;
delay(500);
}
if(kaishi==0)
{
P1=0xff;
}
if(kaishi==2)
{
P1=0xf7;
delay(500);
P1=0xf3;
delay(500);
P1=0xfb;
delay(500);
P1=0xf9;
delay(500);
P1=0xfd;
delay(500);
P1=0xfc;
delay(500);
P1=0xfe;
delay(500);
P1=0xf6;
delay(500);
}
}
} 每个按键要按下去久一点才会有效
如果觉得《单片机控制步进电机程序c语言正反转停止 单片机控制步进电机正反转程序》对你有帮助,请点赞、收藏,并留下你的观点哦!