|
是用51hei單片機(jī)開發(fā)板 電路圖詳見:http://www.zg4o1577.cn/f/51hei-5.pdf 的數(shù)碼管部分, 用2個74hc573 鎖存,p0口作為數(shù)據(jù)口 ,p3.6和p3.7分別是段和位的鎖存端口.- #include<reg52.h>
- #define uchar unsigned char
- #define uint unsigned int
- uchar code SEG7[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
- sbit D=P3^6;
- sbit V=P3^7;
- //==================
- void delay(uint k)
- {
- uint i,j;
- for(i=0;i<k;i++){
- for(j=0;j<121;j++)
- {;}}
- }
- //===================
- void main(void)
- {
- uchar a=7,b=9,c=8;
- uchar temp;
- //==================
- if((c>b)&&(c>a))
- {temp=c;
- c=a;a=temp;}
- else if((b>a)&&(b>c))
- {temp=b;
- b=a;a=temp;}
- //===============
- if(c>b)
- {temp=c;
- c=b;b=temp;}
- //================
- while(1)
- {
- D=1;P0=SEG7[a];D=0;P0=0xff;V=1;P0=0xfe;V=0;delay(5);
- D=1;P0=SEG7[b];D=0;P0=0xff;V=1;P0=0xfd;V=0;delay(5);
- D=1;P0=SEG7[c];D=0;P0=0xff;V=1;P0=0xfb;V=0;delay(5);
- }
- }
復(fù)制代碼
|
|