资源简介
51单片机Protues仿真舵机,可以通过按键实现4个舵机角度的变化,并在LCD1602液晶显示舵机角度。仿真+程序。

代码片段和文件信息
#include
#include
#define uchar unsigned char
#define uint unsigned int
uchar countjb0jb2jb3jb4h;
uchar countjb0_angjb2_angjb3_angjb4_angh;
sbit key0=P0^0;
sbit key1=P0^1;
sbit key2=P0^2;
sbit key3=P0^3;
sbit key4=P0^4;
sbit key5=P0^5;
sbit key6=P0^6;
sbit key7=P0^7;
sbit pwm1=P3^4;
sbit pwm2=P3^5;
sbit pwm3=P3^6;
sbit pwm4=P3^7;
void DelayUs2x(unsigned char t)
{
while(--t);
}
/*------------------------------------------------
mS延时函数,含有输入参数 unsigned char t,无返回值
unsigned char 是定义无符号字符变量,其值的范围是
0~255 这里使用晶振12M,精确延时请使用汇编
------------------------------------------------*/
void DelayMs(unsigned char t)
{
while(t--)
{
//大致延时1mS
DelayUs2x(245);
DelayUs2x(245);
}
}
void Init_Timer1()
{
TMOD |=0x10;
EA=1;
ET1=1;
TR1=1;
}
void main(void)
{
LCD_initial();
LCD_set_position(0);
LCD_prints(“1:“);
LCD_set_position(8);
LCD_prints(“2:“);
LCD_set_position(0x40);
LCD_prints(“3:“);
LCD_set_position(0x40+8);
LCD_prints(“4:“);
Init_Timer1();
jb0=3;jb2=3;jb3=3;jb4=3;
while(1)
{
if(key0 == 0)
{
jb0++;
if(jb0>=8)jb0=8;
while(key0 == 0);
}
if(key1 == 0)
{
jb0--;if(jb0<=3)jb0=3;
while(key1 == 0);
}
if(key2 == 0)
{
jb2++;if(jb2>=8)jb2=8;
while(key2 == 0);
}
if(key3 == 0)
{
jb2--;if(jb0<=3)jb0=3;
while(key3 == 0);
}
if(key4 == 0)
{
jb3++; if(jb2>=8)jb2=8;
while(key4 == 0);
}
if(key5 == 0)
{
jb3--;if(jb3<=3)jb3=3;
while(key5 == 0);
}
if(key6 == 0)
{
jb4++;if(jb4>=8)jb4=8;
while(key6 == 0);
}
if(key7 == 0)
{
jb4--;if(jb4<=3)jb4=3;
while(key7 == 0);
}
LCD_set_position(2);//LCD_printc(‘1‘);LCD_printc(‘2‘);
switch(jb0){
case 3:LCD_printc(‘-‘);LCD_printc(‘9‘);LCD_printc(‘0‘);
break;
case 4:LCD_printc(‘-‘);LCD_printc(‘8‘);LCD_printc(‘0‘);
break;
case 5:LCD_printc(‘-‘);LCD_printc(‘3‘);LCD_printc(‘2‘);
break;
case 6:LCD_printc(‘+‘);LCD_printc(‘1‘);LCD_printc(‘5‘);
break;
case 7:LCD_printc(‘+‘);LCD_printc(‘6‘);LCD_printc(‘2‘);
break;
case 8:LCD_printc(‘+‘);LCD_printc(‘9‘);LCD_printc(‘0‘);
break;
}
LCD_set_position(10);//LCD_printc(‘1‘);LCD_printc(‘2‘);
switch(jb2){
case 3:LCD_printc(‘-‘);LCD_printc(‘9‘);LCD_printc(‘0‘);
break;
case 4:LCD_printc(‘-‘);LCD_printc(‘8‘);LCD_printc(‘0‘);
break;
case 5:LCD_printc(‘-‘);LCD_printc(‘3‘);LCD_printc(‘2‘);
break;
case 6:LCD_printc(‘+‘);LCD_printc(‘1‘);LCD_printc(‘5‘);
break;
case 7:LCD_printc(‘+‘);LCD_printc(‘6‘);LCD_printc(‘2‘);
break;
case 8:LCD_printc(‘+‘);LCD_printc(‘9‘);LCD_printc(‘0‘);
break;
}
LCD_set_position(0x42);//LCD_printc(‘1‘);LCD_printc(‘2‘);
switch(jb3){
case 3:LCD_printc(‘-‘);LCD_printc(‘9‘);LCD_printc(‘0‘);
break;
case 4:
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 78829 2017-05-22 22:03 程序+仿真\1602.DSN
文件 742 2017-05-22 22:03 程序+仿真\1602.PWI
文件 747 2005-11-14 20:12 程序+仿真\hardware.h
文件 78837 2017-05-22 22:01 程序+仿真\Last Loaded 1602.DBK
文件 16161 2017-05-25 22:19 程序+仿真\LCD1602
文件 1912 2017-05-22 21:47 程序+仿真\LCD1602.C
文件 1752 2005-05-25 01:30 程序+仿真\LCD1602.h
文件 2781 2017-05-25 22:19 程序+仿真\LCD1602.hex
文件 61 2017-05-25 22:19 程序+仿真\LCD1602.lnp
文件 4079 2017-05-22 21:47 程序+仿真\LCD1602.LST
文件 18254 2017-05-25 22:19 程序+仿真\LCD1602.M51
文件 6735 2017-05-22 21:47 程序+仿真\LCD1602.OBJ
文件 177 2017-05-25 22:24 程序+仿真\LCD1602.plg
文件 57680 2017-05-25 22:20 程序+仿真\LCD1602.uvopt
文件 13907 2017-05-22 19:41 程序+仿真\LCD1602.uvproj
文件 37 2017-05-22 21:47 程序+仿真\LCD1602.__i
文件 57683 2017-05-25 21:56 程序+仿真\LCD1602_uvopt.bak
文件 0 2017-05-22 15:46 程序+仿真\LCD1602_uvproj.bak
文件 4322 2017-05-23 22:14 程序+仿真\Main1.c
文件 9572 2017-05-23 22:14 程序+仿真\Main1.LST
文件 11392 2017-05-23 22:14 程序+仿真\Main1.OBJ
文件 35 2017-05-23 22:14 程序+仿真\Main1.__i
文件 6376 2009-05-07 14:37 程序+仿真\STARTUP.A51
文件 14052 2017-05-22 15:47 程序+仿真\STARTUP.LST
文件 749 2017-05-22 15:47 程序+仿真\STARTUP.OBJ
目录 0 2017-05-26 08:24 程序+仿真
----------- --------- ---------- ----- ----
386872 26
- 上一篇:趣玩猜谜语小程序 V3.1
- 下一篇:Proteus数字时钟电路仿真.rar
相关资源
- 基于MCS_51单片机的工业屏柜散热方案
- MCS_51单片机与8255A的接口设计
- 51单片机PWM程序,占空比、周期可调整
- 51单片机多功能自行车测速仪
- 00
- 用51单片机实现G代码翻译
- 简易的电阻电容测量电路
- 51单片机基于protues的几个仿真实例
- 51单片机PCB设计图
- PC -- 单片机的串口数据传输系统设计
- 51单片机控制舵机程序
- 步进电机protues仿真
- 51单片机读取温度数据存储到SD卡中并
- 【单片机】51单片机数码管显示万年历
- 毕业设计 单片机 对讲机 protues仿真
- 数据采集系统——ADC0808的应用,单片
- C51单片机汇编指令查询、学习工具集
- 基于8051单片机的红外接收程序
- 51单片机频率计(很简单)
- 数字电压表(源程序 protues仿真)
- 基于51单片机的智能温控器
- 基于51单片机的16*16点阵动态显示
- 基于51单片机的模数转换与数模转换
- 51单片机中使用ucos ii的优缺点转
- 51单片机中使用ucos ii的优缺点
- 8051单片机教程第二十七课:单片机几
- 8051单片机教程第二十六课:矩阵式键
- 适用于STC单片机和51单片机的SX1262驱动
- 基于51单片机的计算器(C51编写,有
- 51单片机大量源码
评论
共有 条评论