第一范文网 - 专业文章范例文档资料分享平台

基于51单片机的打地鼠游戏机1602和led显示模拟(源码齐全)

来源:用户分享 时间:2025/7/27 17:41:21 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

}

start();

write_byte(0xa0); //控制字写1010 000 0(写操作) respons();

write_byte(address);//存储单元地址 respons(); write_byte(date); respons();

stop();

unsigned char read_add(unsigned char address) //往地址中读数据 { }

void getRecord() //读取前三名分数

21

unsigned char date; start();

write_byte(0xa0); //控制字 写 respons();

write_byte(address); //单元地址 respons(); start();

write_byte(0xa1); //控制字读1010 000 1(读操作) respons();

date=read_byte(); //数据 SDA=1; delayus(5); SCL=1; delayus(5); stop(); return date;

//非应答

{ }

void Record() //更新前三并记录分数 { }

void Judge() //判断分数高低 {

topscore[0]=read_add(0);//第一名 name[0][0]=read_add(1); name[0][1]=read_add(2); topscore[1]=read_add(3);//第二名 name[1][0]=read_add(4); name[1][1]=read_add(5); topscore[2]=read_add(6);//第三名 name[2][0]=read_add(7); name[2][1]=read_add(8);

write_add(0,topscore[0]);//第一名 write_add(1,name[0][0]); write_add(2,name[0][1]); write_add(3,topscore[1]);//第二名 write_add(4,name[1][0]); write_add(5,name[1][1]); write_add(6,topscore[2]);//第三名 write_add(7,name[2][0]); write_add(8,name[2][1]);

if(score>topscore[0]) {

topscore[2]=topscore[1];//第二名赋给第三名 name[2][0]=name[1][0];

22

}

name[2][1]=name[1][1];

topscore[1]=topscore[0];//第一名赋给第二名 name[1][0]=name[0][0]; name[1][1]=name[0][1]; topscore[0]=score;

//临时变量赋给第一名

name[0][0]=tempname[0]; name[0][1]=tempname[1];

}else if(score>topscore[1]) {

topscore[2]=topscore[1];//第二名赋给第三名 name[2][0]=name[1][0]; name[2][1]=name[1][1];

topscore[1]=score; //临时变量赋给第二名 name[1][0]=tempname[0]; name[1][1]=tempname[1];

}else if(score>topscore[2]) { }

topscore[2]=score; //临时变量赋给第三名 name[2][0]=tempname[0]; name[2][1]=tempname[1];

//*******************************1602环节*************************************//

void wr_com(unsigned char com) //写指令 {

delayms(5); RS=0;

23

}

EN=0; P0=com; delayms(5); EN=1; delayms(5); EN=0;

void wr_dat(unsigned char dat) { }

void lcd_init() { }

void displayWelcome()

//写数据

delayms(5); RS=1; EN=0; P0=dat; delayms(5); EN=1; delayms(5); EN=0;

//1602初始化设置//

delayms(25); wr_com(0x38); wr_com(0x01); wr_com(0x06); wr_com(0x0c); getRecord();

//设置16*2显示,5*7点阵,8位数据接口 //显示清0,数据指针清0 //写一个字符后地址加一 //设置开显示,不显示光标

//显示欢迎界面

24

基于51单片机的打地鼠游戏机1602和led显示模拟(源码齐全).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c43igv23w3k7f1wl0kif0_6.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top