找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 11879|回复: 1
收起左侧

用8x8点阵LED屏显示的小程序

[复制链接]
ID:77707 发表于 2016-12-11 15:59 | 显示全部楼层 |阅读模式
用8x8点阵屏,显示“I LOVE YOU 生日快乐”,使用STC  89C52RD   P1口和P0 口,有兴趣的可以试试。
#include <reg51.h>
unsigned char code tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char code digittab[][8]={
{0xff,0xbf,0xbd,0xbd,0x81,0xbd,0xbd,0xff},       //I
{0xff,0xf3,0xed,0xdd,0xbb,0xdd,0xed,0xf3},       //?  
{0xff,0xff,0x81,0x7f,0x7f,0x7f,0x81,0xff},          //U
{0xbf,0xaf,0xab,0xab,0x80,0xab,0xa8,0xa7},       //生
{0xff,0xff,0x00,0x76,0x76,0x76,0x00,0xff},       //日
{0xbf,0xa3,0xc0,0xab,0xbf,0xcf,0x00,0xf3},       //快
{0xb7,0xd6,0xa5,0x05,0xe5,0xd1,0xbf,0xff},       //乐
};
unsigned int timecount;
unsigned char cnta;
unsigned char cntb;
void main(void)
{
  TMOD=0x01;
  TH0=(65536-3000)/256;
  TL0=(65536-3000)%256;
  TR0=1;
  ET0=1;
  EA=1;
  while(1)
    {;
         }
}
void t0(void) interrupt 1 using 0
{
  TH0=(65536-2000)/256;
  TL0=(65536-2000)%256;
  P1=0XFF; //消除显示重影问题  
  P0=~digittab[cntb][cnta];
  P1=~(0x01<<cnta);

  cnta++;
  if(cnta==8)
    {
      cnta=0;
    }
  timecount++;
  if(timecount==500)
    {
      timecount=0;
      cntb++;
      if(cntb==7)
        {
          cntb=0;
        }
    }
}

回复

使用道具 举报

ID:430234 发表于 2018-12-4 07:35 | 显示全部楼层
前面的tab有什么特别的作用吗?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表