#define uchar unsigned char #define uint unsigned int #define ulong unsigned long #include <reg52.h> void delay(void) //延時(shí)子程序 { unsigned int i,j; //循環(huán)延時(shí) for(i=0;i<400;i++) { for(j=0;j<121;j++) {;} } } void main(void) //主程序 { uchar code ledp[6]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0x00,0xff, 0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0x00,0xff, 0xfc,0xf9,0xf3,0xe7,0xcf,0x9f,0x3f,0x00,0xff, 0x3f,0x9f,0xcf,0xe7,0xf3,0xf9,0xfc,0x00,0xff, 0xf8,0xf1,0xe3,0xc7,0x8f,0x1f,0x00,0xff, 0x1f,0x8f,0xc7,0xe3,0xf1,0xf8,0x00,0xff, 0xf0,0xe1,0xc3,0x87,0x0f,0x00,0xff, 0x0f,0x87,0xc3,0xe1,0xf0,0x00,0xff, 0xe7,0xc3,0x81,0x00,0xff, 0x81,0xc3,0xe7,0x00,0xff, 0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,0xff,0x00,0xff, 0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00,0xff,0x00,0xff, 0x00,0xff,0x00,0xff};//預(yù)定的寫入P1的值 uchar ledi; //定義一個(gè)變量 while(1) { P1=ledp[ledi]; //P1口讀取預(yù)定值 delay(); //調(diào)用延時(shí)程序 ledi++; //延時(shí)一次后讀入下一個(gè)值 if(ledi==104) //如果讀到最后一個(gè)數(shù)值 { ledi=0; //則將變量置0,從頭開(kāi)始 } } }
獻(xiàn)丑了 |