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

北邮数电实验报告(猜数字)

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

x2<=key1; count1:=2;

else null; end if;

if key1 /= x2 and key1 /= x1 then

x3<=key1; count1:=3; else null; end if;

if key1 /= x3 and key1 /= x1 and key1 /= x2 then

x4<=key1; count1:=0; else null; end if;

when 2 =>

when 3 =>

when others => null;

end case;

如上是将矩阵键盘输入的数字显示在数码管上的代码,同时判断输入的数字不能出现重复,相当于消除了键盘抖动的问题。

count_a:=0; count_b:=0;

if x1=y1 then count_a:=count_a+1;end if; if x2=y2 then count_a:=count_a+1;end if; if x3=y3 then count_a:=count_a+1;end if; if x4=y4 then count_a:=count_a+1;end if; if x1=y2 then count_b:=count_b+1;end if; if x1=y3 then count_b:=count_b+1;end if; if x1=y4 then count_b:=count_b+1;end if; if x2=y1 then count_b:=count_b+1;end if; if x2=y3 then count_b:=count_b+1;end if; if x2=y4 then count_b:=count_b+1;end if; if x3=y1 then count_b:=count_b+1;end if; if x3=y2 then count_b:=count_b+1;end if; if x3=y4 then count_b:=count_b+1;end if; if x4=y1 then count_b:=count_b+1;end if; if x4=y2 then count_b:=count_b+1;end if; if x4=y3 then count_b:=count_b+1;end if;

如上是对A、B的计数,用基本的if语句。

详细程序见附件。

五、 功能说明及资源利用情况

按BTN6按键开始游戏,即可开始用矩阵键盘输入数字,数字不能出现重复(输入了重复的数字时将不会算作输入了数字),如图,输入了6312:

按BTN1按键确定输入的数字即可开始游戏,开始计时:

用矩阵键盘输入猜的数字,数字不允许出现重复,按BTN2按键确定,如图输入1234,出现0和3表示0A3B,并且点阵显示X、蜂鸣器警报表示猜的不对:

当时间结束时仍没有猜对数字时,点阵显示囧表示到时间了:

如果在64秒内猜对了数字,则点阵显示笑脸表示猜对了:

在整个猜数字的过程中均可按BTN7按键重置游戏,再次按BTN6开始。 矩阵键盘顺序: 1 2 3 4 5 6 7 8

搜索更多关于: 北邮数电实验报告(猜数字) 的文档
北邮数电实验报告(猜数字).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c6v37e9c4mr9gaia4886f_4.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top