這是根據上課師傅講的結合keil制作proteus 8.9的999數碼管
999數碼管.png (55.11 KB, 下載次數: 63)
下載附件
2020-11-13 15:16 上傳
- #include <reg51.h>
- #include <intrins.h>
- #define uint unsigned int
- #define uchar unsigned char
- #define out2 P2
- #define out1 P1
- #define out0 P0
- //延時函數
- void delay(uint xms)
- {
- uint i,j,k;
- for(i=xms;i>0;i--)
- {
- for(j=50;j>0;j--);
- for(k=50;k>0;k--);
- }
- }
- //定義P1,p2端口
- uchar code seg2[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
- uchar code seg1[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
- uchar code seg0[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
- //main函數
- void main(void)
- {
- //讓秒的個位開始計數
- uchar i,j,k;
- i=0;
- j=1;
- k=0;
- out1=seg1[0]; //讓秒的十位從0開始亮
- out0=seg0[0]; //讓秒的百位從0開始亮
- while(1)
- {
-
- out2=seg2[i];
- delay(500);
- i++;
- //讓秒的十位開始計數
- if(i%10==0&i>9)
- {
- out1=seg1[j];
- i=0;
- j++;
- }
- if(j%11==0&j>9)
- {
- k++;
- out0=seg0[k];
- j=1;
- }
-
- }
- }
復制代碼
制作的999數碼管
全部資料51hei下載地址:
999.zip
(72.36 KB, 下載次數: 14)
2020-11-13 15:21 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|