{"id":131,"date":"2025-07-20T19:34:40","date_gmt":"2025-07-20T11:34:40","guid":{"rendered":"https:\/\/newknow.top\/?p=131"},"modified":"2025-07-21T14:16:09","modified_gmt":"2025-07-21T06:16:09","slug":"51%e5%8d%95%e7%89%87%e6%9c%ba-%e7%9f%a9%e9%98%b5%e9%94%ae%e7%9b%98%e7%9a%84%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/newknow.top\/index.php\/2025\/07\/20\/51%e5%8d%95%e7%89%87%e6%9c%ba-%e7%9f%a9%e9%98%b5%e9%94%ae%e7%9b%98%e7%9a%84%e5%ae%9e%e7%8e%b0\/","title":{"rendered":"51\u5355\u7247\u673a\u2014\u2014\u77e9\u9635\u952e\u76d8\u7684\u5b9e\u73b0"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">MatrixKey.c<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;REGX52.H>\n#include &lt;Delay.h>\n\/**\n  * @brief  \u77e9\u9635\u952e\u76d8\u8bfb\u53d6\u6309\u952e\u952e\u7801\n  * @param  \u65e0\n  * @retval KeyNumber \u6309\u4e0b\u6309\u952e\u7684\u952e\u7801\u503c\n\u5982\u679c\u6309\u952e\u6309\u4e0b\u4e0d\u653e\uff0c\u7a0b\u5e8f\u4f1a\u505c\u7559\u5728\u6b64\u51fd\u6570\uff0c\u677e\u624b\u7684\u4e00\u77ac\u95f4\uff0c\u8fd4\u56de\u6309\u952e\u952e\u7801\uff0c\u6ca1\u6709\u6309\u952e\u6309\u4e0b\u65f6\uff0c\u8fd4\u56de0\n  *\/\nunsigned char MatrixKey()\n{\n\tunsigned char keynumber=0;\n\tP1=0xFF;\/\/\u5148\u5168\u90e8\u7f6e\u4e3a1\n\tP1_3=0;\n\tif(P1_7==0){Delay(20);while(P1_7==0);Delay(20);keynumber=1;}\n\tif(P1_6==0){Delay(20);while(P1_6==0);Delay(20);keynumber=5;}\n\tif(P1_5==0){Delay(20);while(P1_5==0);Delay(20);keynumber=9;}\n\tif(P1_4==0){Delay(20);while(P1_4==0);Delay(20);keynumber=13;}\n\tP1=0xFF;\n\tP1_2=0;\n\tif(P1_7==0){Delay(20);while(P1_7==0);Delay(20);keynumber=2;}\n\tif(P1_6==0){Delay(20);while(P1_6==0);Delay(20);keynumber=6;}\n\tif(P1_5==0){Delay(20);while(P1_5==0);Delay(20);keynumber=10;}\n\tif(P1_4==0){Delay(20);while(P1_4==0);Delay(20);keynumber=14;}\n\tP1=0xFF;\n\tP1_1=0;\n\tif(P1_7==0){Delay(20);while(P1_7==0);Delay(20);keynumber=3;}\n\tif(P1_6==0){Delay(20);while(P1_6==0);Delay(20);keynumber=7;}\n\tif(P1_5==0){Delay(20);while(P1_5==0);Delay(20);keynumber=11;}\n\tif(P1_4==0){Delay(20);while(P1_4==0);Delay(20);keynumber=15;}\n\tP1=0xFF;\n\tP1_0=0;\n\tif(P1_7==0){Delay(20);while(P1_7==0);Delay(20);keynumber=4;}\n\tif(P1_6==0){Delay(20);while(P1_6==0);Delay(20);keynumber=8;}\n\tif(P1_5==0){Delay(20);while(P1_5==0);Delay(20);keynumber=12;}\n\tif(P1_4==0){Delay(20);while(P1_4==0);Delay(20);keynumber=16;}\n\t\n\treturn keynumber;\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">MatrixKey.h<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#ifndef __MATRIXKEY_H__\n#define __MATRIXKEY_H__\nunsigned char MatrixKey();\n#endif\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">main.c<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;REGX52.H&gt;\n#include &lt;MatrixKey.h&gt;\n#include &lt;LCD1602.h&gt;\nunsigned char keynum;\nvoid main()\n{\n\tLCD_Init();\n\twhile(1)\n\t{\n\t\tkeynum=MatrixKey();\/\/\u5c06MatrixKey()\u7684\u8fd4\u56de\u503c\u8d4b\u503c\u7ed9keynum\n\t\tif(keynum)\n\t\t{\n\t\t\tLCD_ShowNum(1,1,keynum,2);\n\t\t}\n\t}\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e3a\u4ec0\u4e48\u8981\u4f7f\u7528if(keynum)\uff1f<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u6309\u952e\u6309\u4e0b\u65f6\uff0ckeynum\u4e0d\u4e3a0\uff0c\u6267\u884cif\u91cc\u9762\u7684\u51fd\u6570\uff0cLCD1602\u663e\u793a\u6570\u503c<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6309\u952e\u6ca1\u6709\u6309\u4e0b\u65f6\uff0ckeynum\u7b49\u4e8e0\uff0c\u4e0d\u6267\u884cif\u91cc\u9762\u7684\u51fd\u6570<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">\u5982\u679c\u6ca1\u6709if\u5224\u65ad\uff0c\u5b83\u4f1a\u663e\u793a\u7684\u5f88\u5feb\u5c31\u88ab\u4e0b\u4e00\u4e2a\u5faa\u73af\u76840\u66ff\u4ee3\u6389\u76f4\u63a5\u663e\u793a00<\/mark><\/p>\n","protected":false},"excerpt":{"rendered":"<p>MatrixKey.c MatrixKey.h main.c \u4e3a\u4ec0\u4e48\u8981\u4f7f\u7528if(keynum)\uff1f \u6309\u952e\u6309\u4e0b\u65f6\uff0c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kadence_starter_templates_imported_post":false,"footnotes":""},"categories":[5,4],"tags":[],"class_list":["post-131","post","type-post","status-publish","format-standard","hentry","category-5","category-4"],"_links":{"self":[{"href":"https:\/\/newknow.top\/index.php\/wp-json\/wp\/v2\/posts\/131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/newknow.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/newknow.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/newknow.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/newknow.top\/index.php\/wp-json\/wp\/v2\/comments?post=131"}],"version-history":[{"count":4,"href":"https:\/\/newknow.top\/index.php\/wp-json\/wp\/v2\/posts\/131\/revisions"}],"predecessor-version":[{"id":136,"href":"https:\/\/newknow.top\/index.php\/wp-json\/wp\/v2\/posts\/131\/revisions\/136"}],"wp:attachment":[{"href":"https:\/\/newknow.top\/index.php\/wp-json\/wp\/v2\/media?parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/newknow.top\/index.php\/wp-json\/wp\/v2\/categories?post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/newknow.top\/index.php\/wp-json\/wp\/v2\/tags?post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}