{"id":76,"date":"2026-02-25T23:45:25","date_gmt":"2026-02-25T15:45:25","guid":{"rendered":"https:\/\/xlweb.icu\/?p=76"},"modified":"2026-04-22T21:48:23","modified_gmt":"2026-04-22T13:48:23","slug":"%e8%93%9d%e6%a1%a5%e6%9d%af%e5%8d%95%e7%89%87%e6%9c%ba%e8%ae%be%e8%ae%a1%e4%b8%8e%e5%bc%80%e5%8f%91-%e5%a4%a7%e6%a8%a1%e6%9d%bf","status":"publish","type":"post","link":"https:\/\/xlweb.icu\/index.php\/2026\/02\/25\/%e8%93%9d%e6%a1%a5%e6%9d%af%e5%8d%95%e7%89%87%e6%9c%ba%e8%ae%be%e8%ae%a1%e4%b8%8e%e5%bc%80%e5%8f%91-%e5%a4%a7%e6%a8%a1%e6%9d%bf\/","title":{"rendered":"\u84dd\u6865\u676f(\u5355\u7247\u673a\u8bbe\u8ba1\u4e0e\u5f00\u53d1) \u5927\u6a21\u677f"},"content":{"rendered":"\n<p class=\"has-vivid-green-cyan-color has-text-color has-link-color has-large-font-size wp-elements-fbe736a2f99d6d7654ec6bd0e8ba19e5 wp-block-paragraph\"><strong>\u5404\u6a21\u5757\u521d\u59cb\u5316\u51fd\u6570(\u4e0a\u7535\u3001LED\u3001\u77e9\u9635\u952e\u76d8\u3001\u6570\u7801\u7ba1)<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/*----------------------------------\u4e0a\u7535\u521d\u59cb\u5316-----------------------------------*\/\nvoid System_Init()\n{\n\tP0 = 0xFF;\n\tP2 = P2 &amp; 0x1F | 0x80;\n\tP2 = P2 &amp; 0x1F;\n\t\n\tP0 = 0x00;\n\tP2 = P2 &amp; 0x1F | 0xA0;\n\tP2 = P2 &amp; 0x1F;\n}\n\/*---------------------------------LED\u521d\u59cb\u5316\u51fd\u6570--------------------------------*\/\nvoid LED_Set(unsigned char arr , unsigned char status)\n{\n\tstatic unsigned char temp = 0x00;\n\tstatic unsigned char temp_old = 0xFF;\n\t\n\tif(status){\n\t\ttemp |= 0x01 &lt;&lt; arr;\n\t}\n\telse{\n\t\ttemp &amp;= ~(0x01 &lt;&lt; arr);\n\t}\n\tif(temp != temp_old){\n\t\tP0 = ~temp;\n\t\tP2 = P2 &amp; 0x1F | 0x80;\n\t\tP2 &amp;= 0x1F;\n\t\ttemp_old = temp;\n\t}\n}\n\/*-------------------------------\u77e9\u9635\u952e\u76d8\u521d\u59cb\u5316\u51fd\u6570----------------------------*\/\nunsigned char Key_Get()\n{\n\tunsigned char temp = 0;\n\tP44 = 0; P42=1;P35=1;P34=1;\n\tif(P33==0)temp =4;\n\tif(P32==0)temp =5;\n\tif(P31==0)temp =6;\n\tif(P30==0)temp =7;\n\t\n\tP44 = 1; P42=0;P35=1;P34=1;\n\tif(P33==0)temp =8;\n\tif(P32==0)temp =9;\n\tif(P31==0)temp =10;\n\tif(P30==0)temp =11;\n\t\n\tP44 = 1; P42=1;P35=0;P34=1;\n\tif(P33==0)temp =12;\n\tif(P32==0)temp =13;\n\tif(P31==0)temp =14;\n\tif(P30==0)temp =15;\n\t\n\tP44 = 0; P42=1;P35=1;P34=0;\n\tif(P33==0)temp =16;\n\tif(P32==0)temp =17;\n\tif(P31==0)temp =18;\n\tif(P30==0)temp =19;\n\treturn temp;\n}\n\/*-------------------------------\u6570\u7801\u7ba1\u521d\u59cb\u5316\u51fd\u6570----------------------------*\/\nunsigned char code smg_duanxuan&#91;] = {0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0xBF,0xFF};\/\/10- 11\u706d\nunsigned char code smg_weixuan&#91;] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};\n\nvoid Smg_Set(unsigned char wei,duan,point)\n{\n\tP0 = 0xFF;\n\tP2 = P2 &amp; 0x1F | 0xE0;\n\tP2 &amp;= 0x1F;\n\t\n\tP0 = smg_weixuan&#91;wei];\n\tP2 = P2 &amp; 0x1F | 0xC0;\n\tP2 &amp;= 0x1F;\n\tif(point){\n\t\tP0 = smg_duanxuan&#91;duan] &amp; 0x7F;\/\/ 0111 1111\n\t\tP2 = P2 &amp; 0x1F | 0xE0;\n\t\tP2 &amp;= 0x1F;\n\t}\n\telse{\n\t\tP0 = smg_duanxuan&#91;duan];\n\t\tP2 = P2 &amp; 0x1F | 0xE0;\n\t\tP2 &amp;= 0x1F;\n\t}\n}\n\/*--------------------------------------------------------------------------*\/<\/code><\/pre>\n\n\n\n<p class=\"has-text-align-center has-vivid-green-cyan-color has-text-color has-link-color has-large-font-size wp-elements-8ba591e39fe1e10e1f56e6b0d2a47abf wp-block-paragraph\"><strong>\u4e3b\u51fd\u6570\u90e8\u5206<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;STC15F2K60S2.H>\n#include \"INit.h\"\n#include \"LED.h\"\n#include \"smg.h\"\n#include \"Key.h\"\n\nunsigned char key_slow_down;\nunsigned char key_old,key_val,key_down,key_up;\nunsigned int smg_slow_down;\nunsigned char smg_pos;\nunsigned char smg_buf&#91;8] = {1,2,3,4,5,6,7,8};\nunsigned char smg_point&#91;8] = {0,0,0,0,0,0,0,0};\nunsigned char led_buf&#91;8] = {0,0,0,0,0,0,0,0};\n\nvoid Key_Function()\n{\n\tif(key_slow_down)return;\n\tkey_slow_down = 1;\n\tkey_val = Key_Get();\n\tkey_down =  key_val &amp; (key_val ^ key_old);\n\tkey_up = ~key_val &amp; (key_val ^ key_old);\n\tkey_old = key_val;\n}\nvoid smg_Function()\n{\n\tif(smg_slow_down)return;\n\tsmg_slow_down = 1;\n}\n\nvoid LED_Function()\n{\n\t\n}\nvoid Timer0_Init(void)\t\t\/\/1\u6beb\u79d2@12.000MHz\n{\n\tAUXR &amp;= 0x7F;\t\t\t\/\/\u5b9a\u65f6\u5668\u65f6\u949f12T\u6a21\u5f0f\n\tTMOD &amp;= 0xF0;\t\t\t\/\/\u8bbe\u7f6e\u5b9a\u65f6\u5668\u6a21\u5f0f\n\tTL0 = 0x18;\t\t\t\t\/\/\u8bbe\u7f6e\u5b9a\u65f6\u521d\u59cb\u503c\n\tTH0 = 0xFC;\t\t\t\t\/\/\u8bbe\u7f6e\u5b9a\u65f6\u521d\u59cb\u503c\n\tTF0 = 0;\t\t\t\t\/\/\u6e05\u9664TF0\u6807\u5fd7\n\tTR0 = 1;\t\t\t\t\/\/\u5b9a\u65f6\u56680\u5f00\u59cb\u8ba1\u65f6\n\t\n\tET0 = 1;\n\tEA=1;\n}\n\nvoid Timer0_Function() interrupt 1\n{\n\tif(++key_slow_down==10)key_slow_down=0;\n\tif(++smg_slow_down==50)smg_slow_down=0;\n\tif(++smg_pos==8)smg_pos = 0;\n\tSmg_Set(smg_pos,smg_buf&#91;smg_pos],smg_point&#91;smg_pos]);\n\tLED_Set(smg_pos,led_buf&#91;smg_pos]);\n}\nvoid main()\n{\n\tSystem_Init();\n\tTimer0_Init();\n\twhile(1)\n\t{\n\t\tKey_Function();\n\t\tsmg_Function();\n\t\tLED_Function();\n\t}\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5404\u6a21\u5757\u521d\u59cb\u5316\u51fd\u6570(\u4e0a\u7535\u3001LED\u3001\u77e9\u9635\u952e\u76d8\u3001\u6570\u7801\u7ba1) \u4e3b\u51fd\u6570\u90e8\u5206<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-76","post","type-post","status-publish","format-standard","hentry","category-article"],"_links":{"self":[{"href":"https:\/\/xlweb.icu\/index.php\/wp-json\/wp\/v2\/posts\/76","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xlweb.icu\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xlweb.icu\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xlweb.icu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xlweb.icu\/index.php\/wp-json\/wp\/v2\/comments?post=76"}],"version-history":[{"count":2,"href":"https:\/\/xlweb.icu\/index.php\/wp-json\/wp\/v2\/posts\/76\/revisions"}],"predecessor-version":[{"id":78,"href":"https:\/\/xlweb.icu\/index.php\/wp-json\/wp\/v2\/posts\/76\/revisions\/78"}],"wp:attachment":[{"href":"https:\/\/xlweb.icu\/index.php\/wp-json\/wp\/v2\/media?parent=76"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlweb.icu\/index.php\/wp-json\/wp\/v2\/categories?post=76"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlweb.icu\/index.php\/wp-json\/wp\/v2\/tags?post=76"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}