- #include<reg52.h>
- unsigned char code table[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xff,0xff,0x00,0x00,0x55,0x55,0xaa,0xaa};
- void Delay(unsigned int t);
- void main (void)
- {
-
- unsigned char i; //定義了一個無符號字符型局部變量i取值范圍0~255;也就是256位
- while (1) //定義了一個主循環,當while語句中的判斷條件為1即為真,執行while所包含的語句。!1即為假,跳出while循環
- {
- for(i=0;i<16;i++) // 加入for 循環;表明for循環大括號中的程序循環16次,表明表格中有16個元素。
-
- P1=table[i];
- Delay(30000);//延時函數實參為30000
- }
-
- }
- void Delay(unsigned int t)//無返回值,形參延時函數
- {
- while(--t);
- }
復制代碼 |