小白求解按键k2实现一个LED1灯的翻转

2019-11-22 15:40发布

<font color="#333333"><font face="微软雅黑"><font style="font-size:18px">1.<font face="等线">按键</font>k2<font face="等线">实现一个</font>LED1<font face="等线">灯的翻转</font></font></font></font><font color="#333333"><font face="微软雅黑"><font style="font-size:18px">2.<font face="等线">按键</font>k3按下计时,松开按键,单片机串口发送按下的时间(单位ms)</font></font></font><font color="#333333"><font face="微软雅黑"><font style="font-size:18px">3.LED2<font face="等线">闪烁,周期为</font>2s,其中亮1.5<font face="等线">秒,灭</font>0.5<font face="等线">秒,要求时间准确。</font></font></font></font><font color="#333333"><font face="微软雅黑"><font style="font-size:18px"><font face="等线">第三个实现不了</font></font></font></font><pre style="max-width: 100%;"><code class="cpp hljs" codemark="1"><span class="hljs-meta"># <span class="hljs-meta-keyword">define</span> uint unsigned int</span> sbit key2=P3^<span class="hljs-number">4</span>; sbit LED1=P1^<span class="hljs-number">0</span>; uint count1=<span class="hljs-number">0</span>; <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">delay</span><span class="hljs-params">(uint i)</span> <span class="hljs-title">while</span><span class="hljs-params">(--i)</span></span>; <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">init</span><span class="hljs-params">()</span> TMOD</span>=<span class="hljs-number">0x21</span>; TL0=<span class="hljs-number">0x17</span>; TL1=<span class="hljs-number">0xfd</span>; TR0=<span class="hljs-number">1</span>; SM1=<span class="hljs-number">1</span>; ET0=<span class="hljs-number">1</span>; ES=<span class="hljs-number">1</span>; <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">()</span> <span class="hljs-title">init</span><span class="hljs-params">()</span></span>; { { LED1=~LED1; } { { TL0=<span class="hljs-number">0x17</span>; } IF(ti==<span class="hljs-number">1</span>) TI=<span class="hljs-number">0</span>; } } <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">timer</span><span class="hljs-params">()</span> interrupt 1 TH0</span>=<span class="hljs-number">0xfc</span>; count2++; <span class="hljs-keyword">if</span>(count2==<span class="hljs-number">500</span>) <span class="hljs-keyword">if</span>(count2==<span class="hljs-number">2000</span>) LED2=~LED2; } }</code></pre><p><br></p>
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。