標(biāo)題: 分享一個(gè)單片機(jī)代碼 數(shù)碼管從0到9再到0再到9的循環(huán)(歡迎大家提問,及糾正) [打印本頁]

作者: wzjun    時(shí)間: 2017-6-2 23:24
標(biāo)題: 分享一個(gè)單片機(jī)代碼 數(shù)碼管從0到9再到0再到9的循環(huán)(歡迎大家提問,及糾正)
實(shí)現(xiàn)一個(gè)數(shù)碼管從0到9再到0再到9的循環(huán),每隔1S循環(huán)一次(附件為原理圖)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

316.22 KB, 下載次數(shù): 21, 下載積分: 黑幣 -5






歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1