打印

求好心人相助!

[复制链接]
1346|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
gentleman1358|  楼主 | 2010-10-26 17:12 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
这个双色8X8点阵红色显示1,2,3,4,5,6,7,8,9,P,R,,E,C,H,I,N中;正常
担是绿色时显示N时有个边显示不出来;点阵LED没有问题!

程序如下:
/*****************************************************************************************
*                                         *
*                  LED点阵实验(流动显示1 2 3 4 5 6 7 8 9)         *
* 说明 通过P0 和 P2 作为点阵接口                                 *
*要求学员掌握 LED点阵的工作原理和 各点阵脚的定义及接法,具体接线请参考接线说明       *
*我们采用的LED点阵式是低功耗,在做实验时可以用单片机脚直接驱动                          *
******************************************************************************************/

#include<reg51.h>
unsigned char code tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};

unsigned char code digittab[18][8]={
{0x00,0x00,0x3e,0x41,0x41,0x41,0x3e,0x00}, //0
{0x00,0x00,0x00,0x00,0x21,0x7f,0x01,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
{0x00,0x00,0x7F,0x48,0x48,0x30,0x00,0x00}, //P
{0x00,0x00,0x7F,0x48,0x4C,0x73,0x00,0x00}, //R
{0x00,0x00,0x7F,0x49,0x49,0x49,0x00,0x00}, //E
{0x00,0x00,0x3E,0x41,0x41,0x62,0x00,0x00}, //C
{0x00,0x00,0x7F,0x08,0x08,0x7F,0x00,0x00}, //H
{0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00}, //I
{0x00,0x7F,0x10,0x08,0x04,0x7F,0x00,0x00}, //N
{0x7C,0x48,0x48,0xFF,0x48,0x48,0x7C,0x00}  //中
};
unsigned int timecount;
unsigned char cnta;
unsigned char cntb;
void main(void)
{
TMOD=0x01;
TH0=(65536-3000)/256;
TL0=(65536-3000)%256;
TR0=1;    //开启定时0
ET0=1;     
EA=1;    //开启中断
cntb=0;
  
while(1)
{ ;
}
}

/*************************************************
*
*    定时中断
********************************************************/                                      
void t0(void) interrupt 1 using 0
{
  TH0=(65536-3000)/256;  //定时器高位装载数据
  TL0=(65536-3000)%256;  //定时器低位装载数据
  if(cntb<18) //红色
  {
    P1=0xFF;
    P2=tab[cnta];
    P0=digittab[cntb][cnta];
  }
  else //绿色
  {
    P2=0xFF;
    P1=tab[cnta];
    P0=digittab[cntb-18][cnta];
  }

  if(++cnta>=8) cnta=0;
  if(++timecount>=333)
  {
    timecount=0;
    if(++cntb>=36)cntb=0;
  }
}

9 LED点阵.rar

1.05 MB

相关帖子

沙发
gentleman1988| | 2010-12-6 22:05 | 只看该作者
:'(

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

100

帖子

1

粉丝