标题: 单片机点阵显示实验 [打印本页]

作者: zjy_    时间: 2021-1-10 13:49
标题: 单片机点阵显示实验
点阵显示实验
  1. #include <reg51.h>
  2.         unsigned char code tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
  3.         unsigned char code digittab[10][8]={
  4.         {0x00,0x00,0x3e,0x41,0x41,0x41,0x3e,0x00}, //0
  5.         {0x00,0x00,0x00,0x00,0x21,0x7f,0x01,0x00}, //1
  6.         {0x00,0x00,0x27,0x45,0x45,0x45,0x39,0x00}, //2
  7.         {0x00,0x00,0x22,0x49,0x49,0x49,0x36,0x00}, //3
  8.         {0x00,0x00,0x0c,0x14,0x24,0x7f,0x04,0x00}, //4
  9.         {0x00,0x00,0x72,0x51,0x51,0x51,0x4e,0x00}, //5
  10.         {0x00,0x00,0x3e,0x49,0x49,0x49,0x26,0x00}, //6
  11.         {0x00,0x00,0x40,0x40,0x40,0x4f,0x70,0x00}, //7
  12.         {0x00,0x00,0x36,0x49,0x49,0x49,0x36,0x00}, //8
  13.         {0x00,0x00,0x32,0x49,0x49,0x49,0x3e,0x00} //9
  14.         };
  15. unsigned int timecount;        //
  16.         unsigned char lie;        //
  17.         unsigned char shu;         //

  18.         void main(void)
  19.         {
  20.                 TMOD=0x01;
  21.                 TH0=(65536-3000)/256;
  22.                 TL0=(65536-3000)%256;
  23.                 TR0=1;
  24.                 ET0=1;
  25.                 EA=1;
  26.                 while(1);         
  27.         }
  28. void t0(void) interrupt 1        
  29.         {
  30.                 TH0=(65536-3000)/256;
  31.                 TL0=(65536-3000)%256;
  32.                 P3=tab[lie];                 
  33.                 P0=digittab[shu][lie];        
  34.                 lie++;               
  35.                 if(lie==8) lie=0;                 
  36.                 timecount++;
  37.                 if(timecount==333)         
  38.                 {
  39.                         timecount=0;
  40.                         shu++;                 
  41.                         if(shu==10) shu=0;         
  42.                 }
  43.         }
复制代码







欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1