matrix-8*8電子屏 紅色上為列下為行。其他顏色上為行,下為列。這一點要注意。
所有點,行低電平,列高電平時才會亮。
P0口輸出時一定要接上拉電阻。
仿真圖如下:
8*8點陣
暫時還沒寫到按鍵控制,只有簡單的幾個顯示小程序,重點是研究8*8的點亮方式。
單片機程序如下:
- #include <reg52.h>
- #define uint unsigned int
- #define uchar unsigned char
- uchar code taba[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
- uchar code tabb[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
- void delay (uint x)
- {
- uint i,j;
- for (i=x;i>0;i--)
- for(j=110;j>0;j--);
- }
- void main (void)
- {
- uint i,j;
- while(1)
- {
- for(i=0;i<3;i++)
- { for (j=0;j<8;j++)
- {
- P0=taba[i];
- P3=0xff;
- delay (100);
- }
- }
- for (i=0;i<3;i++)
- {
- for (j=0;j<8;j++)
- {
- P0=taba[7-i];
- P3=0xff;
- delay (100);
- }
- }
- for(j=0;j<3;j++)
- {
- for(i=0;i<8;i++)
- {
- P0=0x00;
- P3=tabb[7-i];
- delay(100);
- }
- }
- for(j=0;j<3;j++)
- {
- for(i=0;i<8;i++)
- {
- P0=0x00;
- P3=tabb[i];
- delay(100);
- }
- }
- }
- }
復制代碼
|