P2=1當然只亮1個a點,電路圖也有毛病,給你改了。下面是測試程序。
132943bojaax2rq7qjjoa9.png (114.21 KB, 下載次數: 0)
下載附件
2025-4-17 14:11 上傳
- #include <STC15F2K60S2.H>
- unsigned char code table[]={
- 0x3f,0x06,0x5b,0x4f,
- 0x66,0x6d,0x7d,0x07,
- 0x7f,0x6f,0x77,0x7c,
- 0x39,0x5e,0x79,0x71};
- void Delay(unsigned int t)//1T@11.0592MHz
- {
- unsigned int x;
- while (t--)
- {
- x = 5000;
- while (x--);
- }
- }
- void main()
- {
- unsigned char i;
- while(1)
- {
- P2=0x00;
- P3=~(0x01<<i);
- P2=table[i];
- Delay(1);
- i=++i%8;
- }
- }
復制代碼
|