相关文章

基于单片机的点阵式LED滚动汉字显示屏仿真设计

导读: 点阵显示器的特点是可以按照需要的大小、形状和颜色进行组合,用单片机控制实行各种文字或图型的变化,达到广告宣传和提示的目的。

  AT89C51单片机是8位机,每次只能送出8位数据,因此要向16×16点阵送出16行阳极驱动,需要送两次,或先送上8行,或先送下8行,为了能够实现每一列字型码的完整显示,采用74LS273进行锁存,否则会出现字型残缺现象。根据设计要求并结合图2的硬件连接进行程序设计,程序设计流程图如图3所示。

  利用单片机C语言实现“2008北京欢迎您!”10个字的滚动显示,阿拉伯数字和标点符号按16×8点阵编码,汉字按16×16点阵编码, “2008北京欢迎您!”字型码表如下:

  {0x00,0x00,0x0C,0x1C,0x10,0x24,0x10,0x24,0x10,0x44,0x10,0x84,0x0F,0x0E,0x00,0x00},

  {0x00,0x00,0x07,0xF0,0x08,0x08,0x10,0x04,0x10,0x04,0x08,0x08,0x07,0xF0,0x00,0x00},

  {0x00,0x00,0x07,0xF0,0x08,0x08,0x10,0x04,0x10,0x04,0x08,0x08,0x07,0xF0,0x00,0x00},

  {0x00,0x00,0x0E,0x38,0x11,0x44,0x10,0x84,0x10,0x84,0x11,0x44,0x0E,0x38,0x00,0x00},

  {0x00,0x00,0x0E,0x04,0x08,0x0C,0x08,0x0C,0x08,0x08,0x08,0x10,0xFF,0xFE,0x00,0x00},

  {0x00,0x00,0x3F,0xFC,0x41,0x02,0x42,0x02,0x06,0x02,0x0E,0x06,0x0C,0x0C,0x00,0x00},

  {0x00,0x00,0x20,0x04,0x20,0x08,0x27,0x98,0x24,0xB0,0x24,0x82,0xA4,0x81,0x64,0xFE},

  {0x24,0x80,0x24,0x80,0x24,0xA0,0x27,0xB0,0x60,0x1C,0x20,0x08,0x00,0x00,0x00,0x00},

  {0x28,0x04,0x24,0x08,0x22,0x32,0x21,0xC2,0x26,0xC2,0x38,0x34,0x04,0x04,0x18,0x08},

  {0xF0,0x30,0x17,0xC0,0x10,0x60,0x10,0x18,0x14,0x0C,0x18,0x06,0x10,0x04,0x00,0x00},

  {0x02,0x02,0x82,0x04,0x73,0xF8,0x20,0x04,0x00,0x02,0x3F,0xE2,0x20,0x42,0x40,0x82},

  {0x40,0x02,0x3F,0xFA,0x20,0x02,0x20,0x42,0x20,0x22,0x3F,0xC2,0x00,0x02,0x00,0x00},

  {0x01,0x00,0x02,0x04,0x0C,0x1C,0x3F,0xC0,0xC0,0x1C,0x09,0x02,0x16,0x02,0x60,0x92},

  {0x20,0x4A,0x2F,0x82,0x20,0x02,0x24,0x0E,0x22,0x00,0x31,0x90,0x20,0x0C,0x00,0x00},

  {0x00,0x00,0x00,0x08,0x1F,0xDC,0x3F,0x08,0x3C,0x00,0x30,0x00,0x00,0x00,0x00,0x00},

  {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}。

(a)主程序流程图                    (b)中断服务程序流程图

图3. 程序流程图

  动态扫描显示程序代码如下:

  while (1)

  {for (i=0;i

  { P0=*(p+offset+2*i);

  P2=i|0x90; //P2.4=1,P2.3=0 选中U3, 输出扫描码给U7

  delay();

  P0=*(p+offset+2*i+1);

  P2=i|0x08; //P2.4=0,P2.3=1 选中U2, 输出扫描码给U6

  delay(); }

  for (i=8;i

  { P0=*(p+offset+2*i);

  P2=(i-8)|0xC0; //P2.6=1 P2.5=0, P2.4=0 选中U5,输出扫描码U9

  delay();

  P0=*(p+offset+2*i+1);

  P2=(i-8)|0x20; //P2.5=1 P2.4=0, P2.3=0 选中U4,输出扫描码U8

  delay();

  } }