Proteus仿真8X8点阵显示0到9的数字

小作业,仅供参考

接线如图所示,用的元器件有AT89C51、RESPACK-8,MATRIX-8X8-GREEN

程序代码如下:

#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,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,0x2a,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,0x4f,0x50,0x60,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 hang;
char zi;
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[hang];
  P0=~digittab[zi][hang];
  hang++;
  if(hang==8)//行线到8,复位
  {
    hang=0;
  }
  timecount++;
  if(timecount==333)
  {
    timecount=0;
    zi++;
    if(zi==10)
    {
      zi=0;
    }
  }
}

效果运行良好,快去交作业吧,哈哈哈哈哈!

  • 14
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值