51单片机智能小车在运行同时显示LCD1602的一个问题
#include<reg52.h>#defineuintunsignedint#defineucharunsignedcharsbitEN1=P1^4;sbitEN2=P...
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit EN1=P1^4;
sbit EN2=P1^5;
sbit IN1=P1^2;
sbit IN2=P1^3;
sbit IN3=P1^6;
sbit IN4=P1^7;
sbit KEY=P3^4;
sbit FM=P2^3;
sbit RS=P1^0;
sbit RW=P1^1;
sbit EN=P2^5;
sbit DU=P2^6;
sbit WE=P2^7;
void delay(uint xms)
{
uint x,y;
for(x=xms;x>0;x--)
for(y=112;y>0;y--);
}
void write_com(uchar com)
{
RS=0;
RW=0;
P0=com;
delay(5);
EN=1;
delay(5);
EN=0;
}
void write_date(uchar date)
{
RS=1;
RW=0;
P0=date;
delay(5);
EN=1;
delay(5);
EN=0;
}
void init()
{
DU=0;
WE=0;
EN=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x80);
}
void RUN()
{
write_date("RUNNING");
EN1=1;
EN2=1;
IN1=1;
IN2=0;
IN3=0;
IN4=1;
}
void BACK()
{
EN1=1;
EN2=1;
IN1=0;
IN2=1;
IN3=1;
IN4=0;
}
void LEFT()
{
EN1=1;
EN2=0;
IN1=1;
IN2=0;
}
void RIGHT()
{
EN1=0;
EN2=1;
IN3=0;
IN4=1;
}
void STOP()
{
EN1=0;
EN2=0;
}
void keyscan()
{
A: if(KEY==0)
{
delay(10);
if(KEY==0)
{
FM=0;
while(KEY==0);
FM=1;
}
else
{
goto A;
}
}
else
{
goto A;
}
}
void main()
{
keyscan();
RUN();
delay(2000);
STOP();
}
程序如上,驱动芯片是L293D,为什么加上1602程序后小车不动液晶也没显示了呢
void main()
{
init(); 开头加上init();
} 展开
#define uint unsigned int
#define uchar unsigned char
sbit EN1=P1^4;
sbit EN2=P1^5;
sbit IN1=P1^2;
sbit IN2=P1^3;
sbit IN3=P1^6;
sbit IN4=P1^7;
sbit KEY=P3^4;
sbit FM=P2^3;
sbit RS=P1^0;
sbit RW=P1^1;
sbit EN=P2^5;
sbit DU=P2^6;
sbit WE=P2^7;
void delay(uint xms)
{
uint x,y;
for(x=xms;x>0;x--)
for(y=112;y>0;y--);
}
void write_com(uchar com)
{
RS=0;
RW=0;
P0=com;
delay(5);
EN=1;
delay(5);
EN=0;
}
void write_date(uchar date)
{
RS=1;
RW=0;
P0=date;
delay(5);
EN=1;
delay(5);
EN=0;
}
void init()
{
DU=0;
WE=0;
EN=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x80);
}
void RUN()
{
write_date("RUNNING");
EN1=1;
EN2=1;
IN1=1;
IN2=0;
IN3=0;
IN4=1;
}
void BACK()
{
EN1=1;
EN2=1;
IN1=0;
IN2=1;
IN3=1;
IN4=0;
}
void LEFT()
{
EN1=1;
EN2=0;
IN1=1;
IN2=0;
}
void RIGHT()
{
EN1=0;
EN2=1;
IN3=0;
IN4=1;
}
void STOP()
{
EN1=0;
EN2=0;
}
void keyscan()
{
A: if(KEY==0)
{
delay(10);
if(KEY==0)
{
FM=0;
while(KEY==0);
FM=1;
}
else
{
goto A;
}
}
else
{
goto A;
}
}
void main()
{
keyscan();
RUN();
delay(2000);
STOP();
}
程序如上,驱动芯片是L293D,为什么加上1602程序后小车不动液晶也没显示了呢
void main()
{
init(); 开头加上init();
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询