#include <REGX51.H>
#include <intrins.h>
#include "out.h"
typedef unsigned int uint16_t;
typedef unsigned char uint8_t;
/*电机节拍控制数据表*/
code uint8_t Table[] = {0x08,0x0c,0x04,0x06,0x02,0x03,0x01,0x09}; // +135 +90 +45 0 -45 -90 -135 +180
void Delay10ms();
void Delay20us();
/*
*Function: 电机转动控制
*/
void out(unsigned char y,unsigned char times)
{
int i = 0;
P0 = Table[y];
for(;i<times;i++){
Delay10ms();
}
}
/*
*Function:按键检测控制
*/
uint8_t scan_key()
{
uint8_t isKeyDown = 0x1F;
uint8_t KeyVal = 0;
if(isKeyDown != P1&0x1F)
{
Delay20us();
KeyVal = P1 & 0x1F;
switch(KeyVal)
{
case 0x1E:
return 1;
case 0x1D:
return 2;
case 0x1B:
return 3;
case 0x17:
return 4;
case 0x0F:
return 5;
}
}
return 0;
}
void Delay10ms() //@12.000MHz
{
unsigned char i, j;
i = 117;
j = 184;
do
{
while (--j);
} while (--i);
}
void Delay20us() //@12.000MHz
{
unsigned char i;
_nop_();
_nop_();
i = 57;
while (--i);
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
C51_StepperMotor_Demo.rar (20个子文件)
C51_StepperMotor_Demo
out.h 162B
StepperMotor.uvgui.26239 90KB
Objects
StepperMotor.lnp 137B
main.__i 116B
StepperMotor.hex 1KB
StepperMotor.build_log.htm 1023B
STARTUP.obj 828B
StepperMotor 8KB
out.obj 5KB
main.obj 3KB
out.__i 113B
StepperMotor.uvproj 14KB
STARTUP.A51 6KB
Listings
main.lst 3KB
StepperMotor.m51 9KB
out.lst 3KB
STARTUP.lst 14KB
StepperMotor.uvopt 6KB
main.c 977B
out.c 1KB
共 20 条
- 1
资源评论
Asialing
- 粉丝: 193
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功