单片机课程设计8*8点阵显示

内容提要
正文 硬件功能的设计及描述 源程序代码 且有注释!!
显示 为矿字!! 阿拉伯数字也行

//流水灯的方式测试点阵

#include <reg52.h>

////////////////////////////////////////////////////////

void delay(unsigned int cnt)

{

 while(--cnt);

}

///////////////////////////////////////////////////////

main()

{

 P2=0x00;

 P0=0x55;

 P2=0xfe;//给初始化值

 while(1)

      {

    delay(30000);//delay at crystal frequency in 12MHz

    P2<<=1;//左移一位

    P2|=0x01;//最后一位补1

    

    if(P2==0x7f)//检测是否移到最左端?

          { 

       delay(30000);//delay

          P2=0xfe;

    P0=~P0;

          }

      }

再给你一个显示心形的,其他要显示什么你自己改下数组,点亮相应的点就可以了

/*copyright 2007,ShangHai  HaoTun Electronic Technology co.,Ltd

 *

 *This sample is used for 7-seg led dynamic display .

 *

 *write by Shifang 2007-4-23

 *

 *V1.1

 */

#include <reg52.h>

unsigned char const dofly[]={0x00,0x6C,0x92,0x82,0x44,0x28,0x10,0x00};// 心的形状

unsigned char code seg[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};//分别对应相应的段亮

////////////////////////////////////////////////////////

void delay(unsigned int cnt)

{

 while(--cnt);

}

///////////////////////////////////////////////////////

main()

{

 unsigned char i;

 while(1)

      {

 

       P0=dofly[i];//取显示数据

    P2=seg[i];  //取段码

    delay(200); //扫描间隙延时

    i++;

    if(8==i)

      i=0;

      }

}

温馨提示:答案为网友推荐,仅供参考
相似回答