找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3099|回復(fù): 0
收起左側(cè)

0~9數(shù)字循環(huán)顯示 8*8點(diǎn)陣 單片機(jī)c程序

[復(fù)制鏈接]
ID:769617 發(fā)表于 2020-6-5 16:21 | 顯示全部樓層 |閱讀模式


#include <REGX51.H>
#include<intrins.h>
        #define uchar unsigned char
        #define uint unsigned int
        
unsigned char code tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char code digittab[10][8]={
         //  {0x00,0x18,0x80,0x80,0x08,0x80,0x80,0x1c},
          {0x00,0x00,0x3e,0x41,0x41,0x41,0x3e,0x00},//0
          {0x00,0x00,0x00,0x21,0x7f,0x01,0x00,0x00},//1
          {0x00,0x00,0x27,0x45,0x45,0x45,0x39,0x00},//2
          {0x00,0x00,0x22,0x49,0x49,0x49,0x36,0x00},//3
          {0x00,0x00,0x0c,0x14,0x24,0x7f,0x04,0x00},//4
          {0x00,0x00,0x72,0x51,0x51,0x51,0x4e,0x00},//5
          {0x00,0x00,0x3e,0x49,0x49,0x49,0x26,0x00},//6
          {0x00,0x00,0x40,0x40,0x40,0x4f,0x70,0x00},//7
          {0x00,0x00,0x36,0x49,0x49,0x49,0x36,0x00},//8
          {0x00,0x00,0x32,0x49,0x49,0x49,0x3e,0x00} //9
        };  
//延時
void DelayMS(uint x){
                uchar i;
                while(x--){
                        for(i=0;i<120;i++);
                }
        }


int timecount;
char tnta;
char tntb;
void main(){
        TMOD=0x01;
        TH0=(65535-3000)/256;
        TL0=(65535-3000)%256;
        TR0=1;
        ET0=1;
        EA=1;
        while(1){
                ;
        }


}
void t0(void) interrupt 1 using 0
{
         TH0=(65535-3000)/256;
        TL0=(65535-3000)%256;
        P3=tab[tnta];
        P0=digittab[tntb][tnta];
        tnta++;
        if(tnta==8){
                tnta=0;
        }
        timecount++;
        if(timecount==333){
                timecount=0;
                tntb++;
                if(tntb==10){
                        tntb=0;
                }
        }
}


9NVVQM4B$R{GL)YG6J6O89N.png
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表