给你改了一下试试。
- #include<reg52.h>
- #define LEDPORT P0
- //sbit LED = P0^0;
- sbit ADDR0 = P1^0;
- sbit ADDR1 = P1^1;
- sbit ADDR2 = P1^2;
- sbit ADDR3 = P1^3;
- sbit ENLED = P1^4;
- unsigned char p[] = {
- 0x18, //00011000
- 0x24, //00100100
- 0x42, //01000010
- 0x81, //10000001
- 0x42, //01000010
- 0x24, //00100100
- 0x18 //00011000
- };
- //mS延时函数
- void DelayMs(unsigned int t)
- {
- unsigned int i,j;
- for(i=0;i<t;i++)
- for(j=0;j<148;j++);
- }
- void main()
- {
- int i;
- ENLED = 0;
- ADDR3 = 1;
- ADDR2 = 1;
- ADDR1 = 1;
- ADDR0 = 0;
- //LED = 1;
- while(1)
- {
- for(i=0;i<6;i++)
- {
- LEDPORT = p[i];
- DelayMs(600); //延时600毫秒
- }
- }
- }
复制代码 |