微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 51单片机—8*8LED点阵—09—①

51单片机—8*8LED点阵—09—①

时间:11-25 来源:互联网 点击:
LED点阵,相信肯定知道单片机的人都该知道这个,我也就是一步一步发吧~~

今天这个就是简单的控制8*8LED点阵亮0~F这16个数字,暂时不加左移啊~~,上移啊~~以及16*16的点阵呢~~

不过也就这些天都发出来吧~~

呵呵~~

8*8LED点阵显示0~F(这里是静态显示)

注意:

用Proteus仿真开始还真的不知道那个是行,那个是列~~

还得浪费我时间一点点看人家别人的东东~~

1)红色LED上边为列,下边为行(其它颜色的正好相反,上为行,下为列~~)

2)对于红色来说,上边的列最低位在最右边;下边的行最低位也是恰好相反,在最左边(一会看图就知道了,我的就写反了~~正好可以反过来看了~~)

基本上就这么两点的注意事项~~





然后就是程序了:

LED.c

//------------------------------------------------------------------------------
//以前还真的没仿真过LED点阵,今天正好没事情做~~
//注意一点吧,红色的上为列,下为行,其它颜色正好相反~~(前提是我也没记错的情况下~~呵呵,刚试验了一下,对的~~)
#include"reg52.h"
#include"delay.h"
#include"macroandconst.h"
//------------------------------------------------------------------------------
#define ROW P0
#define LINE P2
uchar code row[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};//送行
uchar code line[16][8]={
{0x1c,0x22,0x22,0x22,0x22,0x22,0x22,0x1c},//0 注意:这里的数据是翻转的,因为对于红色来说,这里上边为列,最低位在最右边,下边为行,最低位在最左边
{0x08,0x0c,0x08,0x08,0x08,0x08,0x08,0x1c},//1
{0x1c,0x22,0x22,0x10,0x08,0x04,0x02,0x3e},//2
{0x1c,0x22,0x20,0x18,0x20,0x20,0x22,0x1c},//3
{0x10,0x18,0x14,0x14,0x12,0x7c,0x10,0x38},//4
{0x3e,0x02,0x02,0x1e,0x20,0x20,0x20,0x1c},//5
{0x1c,0x22,0x02,0x1e,0x22,0x22,0x22,0x1c},//6
{0x3e,0x12,0x10,0x08,0x08,0x08,0x08,0x08},//7
{0x1c,0x22,0x22,0x1c,0x22,0x22,0x22,0x1c},//8
{0x1c,0x22,0x22,0x22,0x3c,0x20,0x22,0x1c},//9
{0x08,0x08,0x18,0x14,0x14,0x3c,0x24,0x66},//A
{0x1e,0x24,0x24,0x1c,0x24,0x24,0x24,0x1e},//B
{0x3c,0x22,0x02,0x02,0x02,0x02,0x22,0x1c},//C
{0x1e,0x24,0x24,0x24,0x24,0x24,0x24,0x1e},//D
{0x3e,0x24,0x14,0x1c,0x14,0x04,0x24,0x3e},//E
{0x3e,0x24,0x14,0x1c,0x14,0x04,0x04,0x0e},//F
};
uchar num;
uchar times;
uchar count;
//------------------------------------------------------------------------------
//main
void main()
{
while(1)
{
for(num=0;num<16;num++)
{
for(times=0;times<50;times++)
{
for(count=0;count<8;count++)//刷新行和列
{
ROW=0XFF;//每次都要消影,就是让行都为低电平
LINE=line[num][count];
ROW=row[count];
delay(2);//延时100ms
}
}
}
}
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top