原理圖:
V}S%)WLKOB17_2(0~19)3%Y.jpg (72.67 KB, 下載次數: 64)
下載附件
2017-11-19 11:58 上傳
單片機源程序如下:
- #ifndef _DEFINE_H_
- #define _DEFINE_H_
- #include <intrins.h>
- //定義數據
- unsigned char Seg_Yang_Led_Table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
- //定義函數
- void Delay1ms() //@11.0592MHz
- {
- unsigned char i, j;
- _nop_();
- _nop_();
- _nop_();
- i = 11;
- j = 190;
- do
- {
- while (--j);
- } while (--i);
- }
- void TestSeg()
- {
- P2 |= 0xc0;
- P0 = 0x80;
- P2 &= ~(0xc0);
- P0 = 0xff;
- P2 |= 0xe0;
- P0 = Seg_Yang_Led_Table[0];
- P2 &= ~(0xe0);
- P0 = 0x00;
- Delay1ms();
- P2 |= 0xc0;
- P0 = 0x40;
- P2 &= ~(0xc0);
- P0 = 0xff;
- P2 |= 0xe0;
- P0 = Seg_Yang_Led_Table[1];
- P2 &= ~(0xe0);
- P0 = 0x00;
- Delay1ms();
- P2 |= 0xc0;
- P0 = 0x20;
- P2 &= ~(0xc0);
- P0 = 0xff;
- P2 |= 0xe0;
- P0 = Seg_Yang_Led_Table[2];
- P2 &= ~(0xe0);
- P0 = 0x00;
- Delay1ms();
- P2 |= 0xc0;
- P0 = 0x10;
- P2 &= ~(0xc0);
- P0 = 0xff;
- P2 |= 0xe0;
- P0 = Seg_Yang_Led_Table[3];
- P2 &= ~(0xe0);
- P0 = 0x00;
- Delay1ms();
- P2 |= 0xc0;
- P0 = 0x08;
- P2 &= ~(0xc0);
- P0 = 0xff;
- P2 |= 0xe0;
- P0 = Seg_Yang_Led_Table[4];
- P2 &= ~(0xe0);
- P0 = 0x00;
- Delay1ms();
-
- P2 |= 0xc0;
- P0 = 0x04;
- P2 &= ~(0xc0);
- P0 = 0xff;
- P2 |= 0xe0;
- P0 = Seg_Yang_Led_Table[5];
- P2 &= ~(0xe0);
- P0 = 0x00;
- Delay1ms();
- P2 |= 0xc0;
- P0 = 0x02;
- P2 &= ~(0xc0);
- P0 = 0xff;
- P2 |= 0xe0;
- P0 = Seg_Yang_Led_Table[6];
- P2 &= ~(0xe0);
- P0 = 0x00;
- Delay1ms();
-
- P2 |= 0xc0;
- P0 = 0x01;
- P2 &= ~(0xc0);
- P0 = 0xff;
- P2 |= 0xe0;
- P0 = Seg_Yang_Led_Table[7];
- P2 &= ~(0xe0);
- P0 = 0x00;
- Delay1ms();
- }
- #endif
復制代碼
|