货车超载自动报警系统
#include
#include
typedef unsigned char uchar;
typedef unsigned int uint;
sbit lcde=P3^5;
sbit rs=P3^4;
sbit rd=P2^7;
sbit wr=P2^6;
sbit Int=P2^5;
sbit playl=P2^2;
sbit playe=P2^1;
sbit REC=P2^0;
uchar code zf[11]={"overweight:"};
uchar code zf2[40]={" huo che chao zai zi dong bao jingxitong"}; uchar code zf3[27]={" condition:"}; uchar code zf4[11]={" condition:"};
uchar code zf5[2]={"01"};
uchar code zf6[10]={"zhengchang"};
uchar *p=zf2,*p1=zf3,*p2=zf4,*p3=zf,*p4=zf6;
uchar temp;
void delay(uint m)
{
while(m--);
}
void wait(uint m)
{
uint n;
for(;m>0;m--)
{
for(n=65535;n>0;n--)
{
_nop_();
_nop_();
_nop_();
_nop_();
}
}
}
void write_cmd1(uchar cmd) //液晶写指令
{
rs=0;
lcde=0;
P1=cmd;
delay(3);
delay(3);
lcde=0;
}
void write_cmd(uchar cmd) //液晶写指令 {
_nop_();
_nop_();
rs=0;
lcde=0;
P1=cmd;
delay(3);
lcde=1;
delay(3);
lcde=0;
}
void write_data(uchar dat) //液晶写数据1 {
_nop_();
_nop_();
rs=1;
lcde=0;
P1=dat;
delay(3);
lcde=1;
delay(3);
lcde=0;
}
void init() //初始化液晶
{
delay(1668);
write_cmd(0x38);
_nop_();
_nop_();
write_cmd(0x0c);
_nop_();
_nop_();
write_cmd(0x06);
_nop_();
_nop_();
write_cmd(0x01);
// write_cmd(0x80);
}
{
REC=0;
delay(20);
}
void play1() //播放语音 {
REC=1;
playl=0;
}
void play2()
{
REC=1;
playe=1;
delay(1);
playe=0;
}
void xianshi()
{
uchar i;
for(i=0;i
{
write_cmd(0x80+i); write_data(zf[i]); i++;
}
for(i=0;i
{
write_cmd(0x80+i); write_data(zf[i]); i++;
}
}
void start_ad()
{
wr=1;
wr=0;
wr=1;
}
void ad_zhixianshi(uchar temp) {
uchar i,temp1,flag;
for(i=0;i
{
temp1=temp;
temp1&=0x80; flag=(bit)(temp1); write_cmd(0x80+i); delay(50000);
write_data(zf5[flag]); temp
}
}
void baojing(uchar *p)
{
uchar i;
for(i=0;i
{
write_cmd(0x80+0x40+i); write_data(*p++); i++;
}
}
void main()
{
uchar i,flag,temp1;
init();
REC=1;
for(i=0;i
{
write_cmd(0x80+i); write_data(*p2++); delay(65535); i++;
}
while(1)
{
P0=0xff;
start_ad();
delay(10);
rd=0;
while(Int==1); temp=P0;
if(temp>100)
{
play1();
baojing(p3);
} } delay(65535); playl=1; } else baojing(p4);