基于单片机四层电梯系统控制系统设计-毕设课设资料
【资源下载】下载地址如下1504:
https://docs.qq.com/doc/DTlRSd01BZXNpRUxl
#include <REGX51.H>
#define uchar unsigned char
#define uint unsigned int
#define FOSC 11059200L
#define T1MS (65536-FOSC/12/1000) //1ms timer calculation method in 12T mode
sbit BEEP = P0^4;
sbit Upward_LED = P0^5;
sbit Down_LED = P0^6;
sbit L4_KEY_Down = P1^7;
sbit L3_KEY_Up = P3^0;
sbit L3_KEY_Down = P3^1;
sbit L2_KEY_Up = P3^2;
sbit L2_KEY_Down = P3^3;
sbit L1_KEY_Up = P3^4;
sbit L1_KEY = P1^0;
sbit L2_KEY = P1^1;
sbit L3_KEY = P1^2;
sbit L4_KEY = P1^3;
sbit Start_KEY = P1^4;
sbit Stop_KEY = P1^5;
sbit Police_KEY = P1^6;
unsigned char code FFW[8]={0xf1,0xf3,0xf2,0xf6,0xf4,0xfc,0xf8,0xf9}; //反转
unsigned char code FFZ[8]={0xf9,0xf8,0xfc,0xf4,0xf6,0xf2,0xf3,0xf1}; //正转
unsigned int K;
//向上是正转
uchar motor_state = 0;//电机状态 -- 2:正转 1:反转 0:不转
uchar motor_circleNumber = 0;//电机圈数
uchar motor_angleNumber = 0;//电机角度
uint motor_count = 0;
uint motor_last_count = 0;
uchar layer_Now = 1;
uchar layer_Last = 1;
uint count = 0;//理解
uchar System_Runing;//系统运行状态
bit timer0_flag = 0;
#define KEY_NULL_PRES 0
#define L4_KEY_Down_PRES 1
#define L3_KEY_Up_PRES 2
#define L3_KEY_Down_PRES 3
#define L2_KEY_Up_PRES 4
#define L2_KEY_Down_PRES 5
#define L1_KEY_Up_PRES 6
#define L1_KEY_PRES 7
#define L2_KEY_PRES 8
#define L3_KEY_PRES 9
#define L4_KEY_PRES 10
#define Start_KEY_PRES 11
#define Stop_KEY_PRES 12
#define Police_KEY_PRES 13