|
我打算利用按键来控制P1.0和P1.2的电平高低来驱动ICL8038产生两路方波脉冲,现在遇到一个问题 启动按钮能够拉低P1.0 P1.2 产生了方波 但是停止按钮不能拉高P1.0 P1.2 不能停止产生方波了 各位老哥 请问我是哪个地方出错了
延时程序,LCD显示程序, 按键扫描程序略
\\\\\\\\\\\\主程序/////////////////////////////////////
#include <reg51.h>
#include "key4x4.h"
#include "lcd1602.h"
#include "delay.h"
#include "fun.h"
#include "timer.h"
void main(void)
{
LCD1602_Init();//LCD1602初始化
while(1)
{
unsigned char tem;
LCD1602_string(0,0,"LINE:");
LCD1602_string(0,8,"ZHUJU:");
LCD1602_string(1,0,"DIR:");
tem=key_scan();
key(tem);
}
}
//////////////功能程序\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
#include <intrins.h>
#include <reg51.h>
#include "fun.h"
#include "delay.h"
#include "lcd1602.h"
int m=1180,n=0;
flag_l=0;
flag_r=0;
flag_zh=0;
zhuju=59;
flag_stop=0;
void key(unsigned char key_code)
{
flag_down=flag_up=down=up=flag_open=0;
switch(key_code)
{
case 2:DIR_L=DIR_R=0;
LCD1602_char(1,4,0x5e);
break;
case 3:flag_stop=1;
flag_auto=flag_manu=0;
LCD1602_string(1,7,"STOP");
break;
case 4:flag_auto=0;
flag_manu=1;
LCD1602_string(1,7,"MANU");
break;
case 5:flag_zh=0;
flag_l=1;
flag_r=0;
LCD1602_char(1,5,0x7f);
break;
case 6:flag_zh=1;
flag_l=flag_r=0;
LCD1602_char(1,5,0x5e);
break;
case 7:flag_zh=flag_l=0;
flag_r=1;
LCD1602_char(1,5,0x7e);
break;
case 8:flag_auto=1;
flag_manu=0;
LCD1602_string(1,7,"AUTO");
break;
case 10:DIR_L=DIR_R=1;
LCD1602_char(1,4,0x76);
break;
case 12:
if(flag_zh==1)
{
PUL_L=PUL_R=0;
if(flag_manu==1)
{
Delay_xms(m);
PUL_L=PUL_R=1;
}
}
else if(flag_l==1)
{
PUL_R=0;
PUL_L=1;
if(flag_manu==1)
{
Delay_xms(m);
PUL_R=1;
}
}
else if(flag_r==1)
{
PUL_L=0;
PUL_R=1;
if(flag_manu==1)
{
Delay_xms(m);
PUL_L=1;
}
}
break;
case 13:m=m+20;
if(m>1800) m=90;
zhuju=zhuju+1;
if(zhuju<=90){LCD1602_2num(0,14,zhuju);}
else LCD1602_2num(0,14,zhuju=90);
break;
case 14:down=1;
while(flag_down==0){LCD1602_string(1,12,"FALL");}
down=0;
while(flag_open==0){LCD1602_string(1,12,"OPEN");}
up=1;
while(flag_up==0){LCD1602_string(1,12,"RISE");}
up=0;
if(n<=99){LCD1602_2num(0,5,n=n+1);}
else LCD1602_2num(0,5,n=0);
LCD1602_string(1,12," ");
break;
case 15:m=m-20;
if(m<1200) m=60;
zhuju=zhuju-1;
if(zhuju>=60){LCD1602_2num(0,14,zhuju);}
else LCD1602_2num(0,14,zhuju=60);
break;
case 16:PUL_L=PUL_R=1;
break;
}
}
|
-
2.png
(143.32 KB, 下载次数: 55)
|