实验14:步进电机+按键控制

加了按键4:停止

硬件图,管脚图和实验13一样

代码:

main.c

#include


typedef unsigned int u16;
typedef unsigned char u8;

#define BJ P1

sbit But1=P3^1	;
sbit But2=P3^0	 ;
sbit But3=P3^2	  ;
sbit But4 =P3^3	  ;

#define PRESS_1 1
#define PRESS_2 2
#define PRESS_3 3
#define PRESS_4 4
#define UNPRESS_0 0

u8 BJBPZ[]={0X0E,0X0C,0X0D,0X09,0X0B,0X03,0X07,0X06};
u8 BJBPF[]={0X06,0X07,0X03,0X0B,0X09,0X0D,0X0C,0X0E};

	int flag=1;
	char mode=0;
	int TZ=0;


void delay_10us(u16 n)
{
 	while(n--);
}

void delay_ms

你可能感兴趣的:(stm单片机专栏,单片机,嵌入式硬件,步进电机,按键)