单片机源程序如下:
- #include <reg52.h>
- #define uchar unsigned char
- #define uint unsigned int
- uchar code Pattern_1[]=
- {
- 0x0A,0x05,0x0A,0x05,0x0A,0x05,0x0F
- };
- uchar code Pattern_2[]=
- {
- 0x0A,0x05,0x0F,0x08,0x04,0x0C,0x02,0x01,0x03,0x0F
- };
- void DelayMS(uint x)
- {
- uchar t;
- while(x--)
- {
- for(t=120;t>0;t--);
- }
- }
- void main()
- {
- uchar i,m,j,k;
- while(1)
- {
- for(i=0;i<7;i++)
- {
- for(m=0;m<3;m++)
- {
- P0=Pattern_1[i];
- DelayMS(100);
- P0=0;
- DelayMS(100);
- }
- }
- for(j=0;j<10;j++)
- {
- for(k=0;k<3;k++)
- {
- P0=Pattern_2[j];
- DelayMS(100);
- P0=0;
- DelayMS(50);
- }
- }
- }
- }
复制代码
Proteus8.16仿真下载:
JD.7z
(35.83 KB, 下载次数: 4)
|