- 1、本文档共22页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
简易计算器(国外英文资料)
简易计算器(国外英文资料)
/ * -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Routine description: use matrix keyboard to simulate simple calculator keyboard: 1, 2, 3 +
4 5 6 -
7 8 9 *
0 C = /
You can do a four-digit plus or minus multiplication division and show it on the 1602 liquid crystal;
Note: C is cleared.
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - * /
# include reg52. H
# include intrins. H
# define uchar unsigned char
# define uint unsigned int
Sbit FMQ = P3 ^ 6; / / buzzer
# define LCD_data P0 / / 1602 data port
Sbit DLED = P3 ^ 4; / / dynamic digital tube switches
Sbit lcden P1 = ^ 1; / / 1602 liquid-crystal power
Sbit LCDRS P1 = ^ 0; / / 1602 LCD data command option
Uchar num, temp, key = 0, biaozhi = 0;
Uint a = 0, b = 0;
Unsigned long int m = 0, n = 0, z = 0; / / the intermediate data will be over 65535, with long integers
Uchar code table4 [] = 0123456789 + - * / C =; / / 1602 use
Uchar table5 [16]. / / 1602 use
Void delay_1ms (uint z) / / delay function
{
Uint x, y;
For x is equal to z, x, , 0, x --.
For (y = 110);
}
Void fengmingqi () / / buzzer
{uint b, r;
For (b = 0; b 50; b + +)
{
FMQ = 0;
R = 50;
FMQ = 1;
R = 50;
}
}
Void write_com (uchar com) / / 1602 write command functions
{
LCDRS = 0; / / select write command mode
P0 = com; / / the command word to be written to the data bus
Delay_1ms (5); / / slightly delayed for data stability
Lcden = 1; / / enable the ability to end up with a high pulse, because the lcden is already zero in the initialization function
Delay_1ms (5); / / slightly delayed
Lcden = 0; / / will enable the ability to set 0 to complete the high pulse
}
Void write_date (uchar date) / / 1602 writes the data function
{
LCDRS = 1; / / select the data schema
P0 = date;
Delay_1ms (5);
Lcden = 1;
Delay_1ms (5);
Lcden = 0;
}
Void init
文档评论(0)