|
這是一段花樣流水燈的代碼,想要燈從兩邊往中間亮,一直循環(huán),但現(xiàn)在最中間的兩盞燈不亮,請問如何解決?
單片機(jī)源程序如下:
#include <reg52.h>
void DelayMs(unsigned int n);
/*------------------*/
void main (void)
{
unsigned char temp =0x7E;
unsigned int temph , templ;
while(1)
{ P1=temp;
DelayMs(2000);
{ temph=temp & 0xf0,templ=temp & 0x0f;
temph=(temph >> 1)|0x80,
templ=(templ << 1)|0x01;
temp=temph|templ;}
if(temp==0xff)
temp=0x7E; }
}
/*---------------------*/
void DelayMs(unsigned int n)
{
unsigned int i,j;
for(i=0;i<n;i++)
{ for(j=110;j>0;j--); }
}
|
-
1.jpg
(354.3 KB, 下載次數(shù): 45)
下載附件
2021-9-6 16:33 上傳
-
2.jpg
(494.48 KB, 下載次數(shù): 35)
下載附件
2021-9-6 16:33 上傳
|