|
實現一個數碼管從0到9再到0再到9的循環,每隔1S循環一次(附件為原理圖)P1接J16,P0接J12
#include "reg51.h"
#define uchar unsigned char
#define uint unsigned int
uchar code table_numberP[] = {0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
uchar code table[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
uint n;
uint ge;
void main()
{
ge = 0;
TMOD = 0x01;
TH0 = (65536-45872)/256;
TL0 = (65536-45872)%256;
EA = 1;
ET0 = 1;
TR0 = 1;
while(1);
}
void T0_time()interrupt 1
{
TH0 = (65536-45872)/256;
TL0 = (65536-45872)%256;
n++;
if(n%20 == 0)
{
if(ge<=9){
P1 = table_numberP[0];
P0 = table[ge];
ge++;
if(ge == 10){
ge = 0;
}
}
}
}
|
-
-
EM3_V3.0原理圖.pdf
2017-6-2 23:22 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
316.22 KB, 下載次數: 21, 下載積分: 黑幣 -5
|