基于51单片机的公交车报站系统程序Word文档格式.docx

上传人:b****1 文档编号:4167745 上传时间:2023-05-02 格式:DOCX 页数:36 大小:21.06KB
下载 相关 举报
基于51单片机的公交车报站系统程序Word文档格式.docx_第1页
第1页 / 共36页
基于51单片机的公交车报站系统程序Word文档格式.docx_第2页
第2页 / 共36页
基于51单片机的公交车报站系统程序Word文档格式.docx_第3页
第3页 / 共36页
基于51单片机的公交车报站系统程序Word文档格式.docx_第4页
第4页 / 共36页
基于51单片机的公交车报站系统程序Word文档格式.docx_第5页
第5页 / 共36页
基于51单片机的公交车报站系统程序Word文档格式.docx_第6页
第6页 / 共36页
基于51单片机的公交车报站系统程序Word文档格式.docx_第7页
第7页 / 共36页
基于51单片机的公交车报站系统程序Word文档格式.docx_第8页
第8页 / 共36页
基于51单片机的公交车报站系统程序Word文档格式.docx_第9页
第9页 / 共36页
基于51单片机的公交车报站系统程序Word文档格式.docx_第10页
第10页 / 共36页
基于51单片机的公交车报站系统程序Word文档格式.docx_第11页
第11页 / 共36页
基于51单片机的公交车报站系统程序Word文档格式.docx_第12页
第12页 / 共36页
基于51单片机的公交车报站系统程序Word文档格式.docx_第13页
第13页 / 共36页
基于51单片机的公交车报站系统程序Word文档格式.docx_第14页
第14页 / 共36页
基于51单片机的公交车报站系统程序Word文档格式.docx_第15页
第15页 / 共36页
基于51单片机的公交车报站系统程序Word文档格式.docx_第16页
第16页 / 共36页
基于51单片机的公交车报站系统程序Word文档格式.docx_第17页
第17页 / 共36页
基于51单片机的公交车报站系统程序Word文档格式.docx_第18页
第18页 / 共36页
基于51单片机的公交车报站系统程序Word文档格式.docx_第19页
第19页 / 共36页
基于51单片机的公交车报站系统程序Word文档格式.docx_第20页
第20页 / 共36页
亲,该文档总共36页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

基于51单片机的公交车报站系统程序Word文档格式.docx

《基于51单片机的公交车报站系统程序Word文档格式.docx》由会员分享,可在线阅读,更多相关《基于51单片机的公交车报站系统程序Word文档格式.docx(36页珍藏版)》请在冰点文库上搜索。

基于51单片机的公交车报站系统程序Word文档格式.docx

//上一次显示指针偏移量

unsignedcharzm_last=0;

unsignedchark=0;

unsignedchar*q2;

unsignedintsecret=0;

//录音密码

unsignedintymcode=255;

//红外线编码

bitflag0=1;

//译码标志位

bits;

bithw=0;

//解码成功失败标志位

bitmode=0;

//模式选择,0:

报站模式,1录音模式(录音需要输入密码)。

bitxs=0;

//显示输入密码标志位

bitly=0;

//录音允许位

sbitP1_0=P3^7;

//红外线信号输入断口

sbitPLAY=P3^3;

//放音

sbitREC=P3^2;

//录音

sbitLCD_RS=P3^4;

//数据、命令选择信号

sbitLCD_WR=P3^5;

//读写信号

sbitLCD_E=P3^6;

//使能信号

unsignedinttm=0;

unsignedcharcodegImage_word0[1024];

unsignedcharcodegImage_word2[1024];

unsignedcharcodetable0[]={"

虎泉桌刀泉广阜屯街道口洪山丁字桥傅家坡大东门阅马场下一站:

"

};

unsignedcharcodetable1[]={"

深圳市勤正达电子有限公司成立于2002年,是专业研发及生产液晶显示器"

"

和液晶模块的高新技术企业。

LCD显示器覆盖了多种系列多年来公司秉承"

全力面向客户,技术专攻的经营理念,一直致力于为广大电子成品制造商"

提供质量精良,性能稳定,品种齐全的LCD显示屏及LCM显示模块系列产"

品。

望成为您的首选合作伙伴。

"

unsignedcharcodetable2[]={"

请输入密码:

录音模式"

密码错误!

voidmain()

{

unsignedcharnum=0;

unsignedinti=0;

unsignedchar*q;

TMOD=0x11;

TH1=0xF0;

TL1=0x60;

EA=1;

ET1=1;

REC=1;

PLAY=1;

Delay(100);

Lcd_system();

//系统初始化

q=gImage_word2;

Disp_pucture(q);

delay0(30000);

q=gImage_word0;

delay0(40000);

Clear();

while

(1)

{

q=table1;

for(num=0;

num<

5;

num++)

{

if(0==mode)

{

Disp_word0(0,q,32);

q=q+64;

}

for(i=0;

i<

60000;

i++)

bus_contorl();

}

}

}

/***************************************

*名称:

Clear()

*说明:

*功能:

清除全屏显示

*参数:

*返回值:

****************************************/

voidClear()

Write_com(0x01);

Write_com(0x34);

Write_com(0x30);

Lcd_system()

系统初始化

voidLcd_system(void)

Delay(600);

LCD_E=0;

Delay(10000);

Write_com(0x06);

Write_com(0x0c);

Delay(unsignedintt)

延时

t:

延时长度

voidDelay(unsignedintt)

unsignedinti;

for(i=0;

t;

{;

;

Write_com(unsignedchard)

写命令字

d:

命令代码

voidWrite_com(unsignedchard)

LCD_RS=0;

LCD_WR=0;

P1=d;

LCD_E=1;

Delay(40);

LCD_WR=1;

Write_data(unsignedchard)

写数据

d:

需要写入的数据

voidWrite_data(unsignedchard)

LCD_RS=1;

unsignedcharRead_data(void)

读数据

读出数据

unsignedcharRead_data(void)

unsignedchard=0;

Delay(50);

d=P1;

return(d);

Disp_word0(unsignedcharposx,unsignedchar*p,unsignedcharn)

显示一串汉字

pos:

显示位置(第一行:

0-6,第二行:

7-13),

p:

汉字码的地址指针,

n:

显示字的个数,

voidDisp_word0(unsignedcharposx,unsignedchar*p,unsignedcharn)

unsignedchari=0;

unsignedcharpos;

n;

pos=posx;

if((pos<

8)||((pos>

15)&

&

(pos<

24)))

if(pos>

15)pos=pos-8;

Write_com(0x80|pos);

Write_data(p[0]);

Write_data(p[1]);

else

if(pos<

16)

pos=pos-8;

else

pos=pos-16;

}

Write_com(0x90|pos);

posx++;

p=p+2;

Disp_row(unsignedcharrow,unsignedcharpos,unsignedchardat)

显示一个字母或数字

row:

行选择,pos:

显示位置(0-15),dat:

数字码

voidDisp_row(unsignedcharrow,unsignedcharpos,unsignedchardat)

unsignedchardat0;

unsignedcharpos0;

row=row%2;

row=row<

<

4;

pos0=pos/2;

if((pos+1)/2==pos0)

Write_com((0x80+row)|pos0);

Write_data(dat);

else

dat0=Read_data();

Disp_char(unsignedcharpos,unsignedchardat)

0-15,第二行:

16-31,第一行:

32-47,第二行:

48-63),dat:

voidDisp_char(unsignedcharpos,unsignedchardat)

if(pos<

Disp_row(0,pos,dat);

if((pos<

32)&

(pos>

15))

Disp_row(1,pos-16,dat);

48)&

31))

Disp_row(2,pos-16,dat);

64)&

47))

Disp_row(3,pos-32,dat);

voidDisp_number(unsignedcharpos,unsignedlongdat)

显示一个数(0-65536)

显示位置,dat:

显示数据

voidDisp_number(unsignedcharpos,unsignedintdat)

unsignedintd;

unsignedcharaddr;

unsignedchartab[5]={0};

//

d=dat;

while(d)

tab[i]=d%10;

d=d/10;

i++;

if(i<

p_last)

for(addr=0;

addr<

p_last-i;

addr++)

Disp_char(addr+pos+i,0x20);

i;

Disp_char(addr+pos,tab[i-addr-1]+48);

Disp_char(addr+pos,tab[i-addr-1]+48);

if(0==i)Disp_char(pos,48);

p_last=i;

/**********************

*

delay0()

晶振采用24.0MHz

*延时(t*0.1)ms

*输入:

t(时间参数)

***********************/

voiddelay0(unsignedintt)

tm=t;

do

TH0=0xFF;

TL0=0x38;

TR0=1;

while(!

TF0);

TF0=0;

TR0=0;

}while(--tm);

time1()

监视红外线信号是否结束

*如果2ms内输入信号没有沿跳变,就结束译码

flag0

voidtime1()interrupt3using2

flag0=0;

bithw_yima()

红外线译码

ym:

解码成功

(1),失败(0)。

bithw_yima()

unsignedintymdata=0;

unsignedcharn=0;

bitym=0;

ymcode=0xffff;

s=P1_0;

if(0==P1_0)

while(flag0)

while(P1_0==s);

if(1==flag0)

TR1=0;

TH1=0xF0;

TL1=0x60;

TR1=1;

delay0(12);

ymdata=ymdata<

1;

if(0==P1_0)

{

ymdata|=0x01;

}

n++;

s=P1_0;

if(n>

9)//此参数直接影响接受的灵敏度

ymcode=ymdata>

>

ymcode=~ymcode;

ym=1;

//解码成功

delay0(400);

//减少连码

ym=0;

//解码失败

ym=0;

//解码失败

flag0=1;

return(ym);

voidReport(unsignedcharsl)

根据参数报公车站名

sl:

车站序号

voidReport(unsignedcharsl)

unsignedchar*q0;

switch(sl)

case0:

P0=0x00;

PLAY=0;

break;

case1:

P0=0x28;

case2:

P0=0x30;

case3:

P0=0x38;

case4:

P0=0x40;

case5:

P0=0x48;

case6:

P0=0x50;

case7:

P0=0x58;

case8:

P0=0x78;

default:

break;

PLAY=1;

if(sl<

9)

Clear();

q0=table0+6*sl;

Disp_word0(9,q0,3);

if(sl==8)

P0=0x60;

delay0(10000);

PLAY=0;

delay0(1000);

PLAY=1;

P0=0x68;

delay0(10000);

PLAY=0;

delay0(1000);

PLAY=1;

P0=0x80;

delay0(40000);

if(sl<

8)

q0=table0+54;

Disp_word0(9,q0,4);

q0=table0+6*sl+6;

Disp_word0(13,q0,3);

P0=0x70;

P0=0x28+sl*8;

voidRec_bus(unsignedcharrec)

录入公车站名

rec:

录音键的键值

voidRec_bus(unsignedcharrec)

unsignedcharsi=0;

unsignedcharsi_last=0;

si=rec;

if(si!

=si_last)

P0=0x00;

if(si==56)

P0=0x00;

REC=0;

delay0(48000);

//欢迎您乘坐803路公交车,这里是起点站虎泉

REC=1;

P0=0x28;

delay0(8500);

//卓刀泉

P0=0x30;

//广阜屯

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 农林牧渔 > 林学

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2