8*8点阵程序,我检查很多次,都看不出程序的问题,可还是会有一个警告,麻烦各位大佬帮忙看一下,这到底是哪里出问题了
单片机源程序如下:
- // ***************************************************************************************/
- #include "reg51.h" //此文件中定义了单片机的一些特殊功能寄存器
- #include<intrins.h>
- typedef unsigned int u16; //对数据类型进行声明定义
- typedef unsigned char u8;
- sbit SRCLK=P3^6;
- sbit RCLK=P3^5;
- sbit SER=P3^4;
- sbit buzzer=P1^5;
- unsigned char code ledduan[17][8]={
- {0x00,0x00,0x3e,0x41,0x41,0x41,0x3e,0x00},
- {0x00,0x00,0x24,0x7C,0x04,0x00,0x00,0x00},
- {0x00,0x00,0x26,0x4A,0x52,0x22,0x00,0x00},
- {0x00,0x00,0x2A,0x2A,0x2A,0x3E,0x00,0x00},
- {0x00,0x08,0x18,0x28,0x7E,0x08,0x00,0x00},
- {0x00,0x00,0x7A,0x4A,0x4E,0x00,0x00,0x00},
- {0x00,0x00,0x7E,0x4A,0x4E,0x00,0x00,0x00},
- {0x00,0x40,0x40,0x40,0x7E,0x00,0x00,0x00},
- {0x00,0x7E,0x4A,0x4A,0x7E,0x00,0x00,0x00},
- {0x00,0x7A,0x4A,0x4A,0x7E,0x00,0x00,0x00},
- {0x00,0x7A,0x4A,0x4A,0x7E,0x00,0x00,0x00},
- {0x00,0x00,0x7E,0x48,0x78,0x00,0x00,0x00},
- {0x00,0x00,0x7E,0x48,0x48,0x00,0x00,0x00},
- {0x40,0x40,0x7E,0x40,0x40,0x00,0x00,0x00},
- {0x00,0x00,0x3E,0x02,0x02,0x00,0x00,0x00},
- {0x00,0x00,0x3E,0x02,0x3E,0x00,0x00,0x00},
- {0x00,0x30,0x48,0x24,0x24,0x48,0x30,0x00}
- } ;
- unsigned char code ledwei[8]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
- void delay1(u16 i)
- {
- while(i--);
- }
- void beep()
- {
- u16 i;
- for(i=0;i<100;i++)
- {
- delay1(100);
- buzzer=~buzzer;
- }}
- void delay(unsigned int time)
- {
- unsigned int i,j;
- for (i=0;i<time;i++)
- for (j=0;j<121;j++);
-
- }
- /*******************************************************************************
- * 函数名 : Hc595SendByte(u8 dat)
- * 函数功能 : 向74HC595发送一个字节的数据,从高位开始到低位
- * 输入 : 无
- * 输出 : 无
- *******************************************************************************/
- void Hc595SendByte(u8 dat)
- {
- u8 a;
- SRCLK=0;
- RCLK=0;
- for(a=0;a<8;a++)
- {
- SER=dat>>7;//运算时,先将dat的值复制到一个临时单元,向右移位运算的是临时单元的值,而不是dat,所以移位后, dat的值不变。
- dat<<=1;
- SRCLK=1;
- _nop_();
- _nop_();
- SRCLK=0;
- }
- RCLK=1;
- _nop_();
- _nop_();
- RCLK=0;
- }
- /*******************************************************************************
- * 函 数 名 : main
- * 函数功能 : 主函数
- * 输 入 : 无
- * 输 出 : 无
- *******************************************************************************/
- void main()
- {
- unsigned char tab,j;
- unsigned int i;
- while(1)
- {
-
- for (i=0;i<50;i++)
- { for(tab=0;tab<8;tab++)
- { Hc595SendByte(0x00);//消隐,去掉重影
- P0=ledwei[tab];
- Hc595SendByte(ledduan[j][tab]);
- delay(2);
-
- }
- }
- }
- j++;
- beep();
- if(j==17)
- {
- j=0;
- }
- }
复制代码
|