led点阵点亮一个点_LED点阵显示数字

LEDs

378人已加入

描述

  led点阵点亮一个点

  开发板led点阵模块电路图如下:

  

  74HC595:74HC595是一个8位串行输入、并行输出的位移缓存器。芯片第11角为数据输入时钟线,上升沿有效。芯片第12脚为输出存储器锁存时钟线,上升沿有效。芯片第13脚为输出有效(低电平)。芯片第14脚为串行数据输入。

  为表示出输入74HC595的8位二进制数,开发板加入了led模块(图一中绿色所示)。若要使led发光,则需将JP595接vcc。

  OE为输出有效控制端,低电平有效,所以务必将JOE短接片短接到GND端。

  _nop_();函数为延时一个机器周期,所对应头文件为intrins.h

  #include《reg52.h》#include《intrins.h》#define uc unsigned charsbit srclk=P3^6;sbit rclk=P3^5;sbit ser=P3^4;void c74hc595(uc dat){ uc i; srclk=rclk=0; for(i=1;i《=8;i++) { ser=dat》》7; dat《《=1; srclk=1; _nop_(); srclk=0; } rclk=1; _nop_(); rclk=0;}void main(){ c74hc595(0x80); P0=0x7f; while(1);}

  LED8X8点阵显示数字0-9数字

  下面是电路图:

  

  /* 名称:8X8LED点阵显示数字

  说明:1.8X8LED点阵屏循环显示数字0~9,刷新过程为动态变换完成。

  2.行扫描为XX,接P1口,列扫描为YY,接P3口

  */

  #include《reg51.h》

  #include《intrins.h》

  #define uchar unsigned char

  #define uint unsigned int

  uchar code XX[]=

  {

  0x00,0x3e,0x41,0x41,0x41,0x3e,0x00,0x00, //0

  0x00,0x00,0x00,0x21,0x7f,0x01,0x00,0x00, //1

  0x00,0x27,0x45,0x45,0x45,0x39,0x00,0x00, //2

  0x00,0x22,0x49,0x49,0x49,0x36,0x00,0x00, //3

  0x00,0x0c,0x14,0x24,0x7f,0x04,0x00,0x00, //4

  0x00,0x72,0x51,0x51,0x51,0x4e,0x00,0x00, //5

  0x00,0x3e,0x49,0x49,0x49,0x26,0x00,0x00, //6

  0x00,0x40,0x40,0x40,0x4f,0x70,0x00,0x00, //7

  0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00, //8

  0x00,0x32,0x49,0x49,0x49,0x3e,0x00,0x00 //9

  };

  uchar code YY[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};

  uchar i,k,j,t=0,Num_Index;

  void yanchi(uchar ms)

  {

  while(ms--)

  {

  for (i=0;i《100;i++);

  }

  }

  //主程序

  void main()

  {

  while(1)

  {

  for(t=0;t《10;t++)

  {

  for(j=0;j《50;j++)

  {

  for(k=0;k《8;k++)

  {

  P1=YY[k];

  P3=~XX[t*8+k];

  yanchi(2);

  }

  }//**************************0

  }

  }

  }

  /*******************************************************************************************/

  #include《reg51.h》

  #include《intrins.h》

  #define uchar unsigned char

  #define uint unsigned int

  uchar code XX[]=

  {

  0x00,0x3e,0x41,0x41,0x41,0x3e,0x00,0x00, //0

  0x00,0x00,0x00,0x21,0x7f,0x01,0x00,0x00, //1

  0x00,0x21,0x43,0x45,0x49,0x31,0x00,0x00, //2

  0x00,0x22,0x49,0x49,0x49,0x36,0x00,0x00, //3

  0x00,0x0c,0x14,0x24,0x7f,0x04,0x00,0x00, //4

  0x00,0x72,0x51,0x51,0x51,0x4e,0x00,0x00, //5

  0x00,0x3e,0x49,0x49,0x49,0x26,0x00,0x00, //6

  0x00,0x40,0x40,0x4f,0x50,0x60,0x00,0x00, //7

  0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00, //8

  0x00,0x32,0x49,0x49,0x49,0x3e,0x00,0x00 //9

  };

  uchar code YY[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};

  uint i,k,j,t;

  void yanchi(uchar ms)

  {

  while(ms--)

  {

  for (i=0;i《100;i++);

  }

  }

  //主程序

  void main()

  {

  while(1)

  {

  for(t=0;t《200;t++)

  {

  for(j=0;j《20;j++)

  {

  for(k=0;k《8;k++)

  {

  P1=YY[k];

  P2=~XX[(t%10)*8+k];

  P3=~XX[((t%100)/10)*8+k];

  P0=~XX[(t/100)*8+k];

  yanchi(2);

  }

  }//**************************0

  }

  }

  }
责任编辑:YYX

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分