簡易的8X8點(diǎn)陣,拿去
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
單片機(jī)源程序如下:
- #include <reg52.h>
- #include <intrins.h>
- #define uchar unsigned char
- #define uint unsigned int
- void delayms(unsigned int n);
- sbit KEY=P2^0;
- sbit KEY1=P2^1;
- sbit KEY2=P2^2;
- //添加取模記得定義數(shù)組數(shù)量
- uchar code M[11][8]=
- {
- {0x00,0x3e,0x41,0x41,0x41,0x3e,0x00,0x00},
- {0x00,0x00,0x00,0x21,0x7f,0x01,0x00,0x00},
- {0x00,0x27,0x45,0x45,0x45,0x39,0x00,0x00},
- {0x00,0x22,0x49,0x49,0x49,0x36,0x00,0x00},
- {0x00,0x0c,0x14,0x24,0x7f,0x04,0x00,0x00},
- {0x00,0x72,0x51,0x51,0x51,0x4e,0x00,0x00},
- {0x00,0x3e,0x49,0x49,0x49,0x26,0x00,0x00},
- {0x00,0x40,0x40,0x40,0x4f,0x70,0x00,0x00},
- {0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00},
- {0x00,0x32,0x49,0x49,0x49,0x3e,0x00,0x00},
- {0x00,0x20,0x30,0x38,0x3c,0x3e,0x00,0x00}
- };
- uchar i,j;
- void main()
- {
- P0 = 0xff;
- P1 = 0xff;
- P2 = 0xff;
-
- TMOD = 0x01;
- TH0 = (65535-2000)/256;
- TL0 = (65535-2000)%256;
- IT0 = 1;
- IE = 0x83;
- i = 0xfc; //開頭修改這即可
- while(1)
- {
- if(!KEY)
- {
- delayms(100);
- while(!KEY)
- {
- P0 = 0xff;
- P1 = 0x80;
- j = 0;
- i = (i+1)%11;
- }
- }
- if(!KEY1)
- {
- delayms(100);
- while(!KEY1)
- {
- P0 = 0xff;
- P1 = 0x80;
- j = 0;
- i = (i+1)%11;
- }
- }
- if(!KEY2)
- {
- delayms(100);
- while(!KEY2)
- {
- P0 = 0xff;
- P1 = 0x80;
- j = 0;
- i = (i+1)%11;
- }
- }
- }
- }
- void Key_Down() interrupt 0 //中斷
- {
- P0 = 0xff;
- P1 = 0x80;
- j = 0;
- i = (i+1)%11;
- TR0 = 1;
- }
- void Show_Dot_Matrix() interrupt 1
- {
- TH0 = (65535-2000)/256;
- TL0 = (65535-2000)%256;
- P1 = _crol_(P1,1); //循環(huán)左移
- P0 = ~M[i][j];
- j=(j+1)%8;
- }
- void delayms(unsigned int n)
- {
- unsigned int i,j;
- for(j=n;j>0;j--)
- for(i=112;i>0;i--);
- }
復(fù)制代碼
仿真代碼51hei附件下載:
8X8點(diǎn)陣.zip
(56.46 KB, 下載次數(shù): 38)
2021-12-6 11:29 上傳
點(diǎn)擊文件名下載附件
|