#define uchar unsigned char #define uint unsigned int #define ulong unsigned long #include <reg52.h> void delay(void) //延时子程序 { unsigned int i,j; //循环延时 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};//预定的写入P1的值 uchar ledi; //定义一个变量 while(1) { P1=ledp[ledi]; //P1口读取预定值 delay(); //调用延时程序 ledi++; //延时一次后读入下一个值 if(ledi==104) //如果读到最后一个数值 { ledi=0; //则将变量置0,从头开始 } } }
献丑了 |