|
一個(gè)簡(jiǎn)單的流水燈問(wèn)題,在調(diào)用子程序的時(shí)候,led_flow(); ()里面一定需要有參數(shù)嗎,我沒(méi)有寫(xiě)參數(shù),但是也能正確運(yùn)行,但是沒(méi)有參數(shù)的話,又是怎么傳到子程序的呢
代碼如下:
#include<reg51.h>
void delay(int x)
{
int i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);
}
void led_flow(unsigned char *p)
{
P1=*p;
delay(1000);
}
void main(void)
{
unsigned char Tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xff};
unsigned char *pointer;
pointer=Tab;
while(1)
{
if(*pointer==0xff)
pointer=Tab;
led_flow();
*pointer++;
}
}
|
-
捕獲.PNG
(133.08 KB, 下載次數(shù): 20)
下載附件
2020-3-30 11:39 上傳
|