LED點陣,相信肯定知道單片機的人都該知道這個,我也就是一步一步發(fā)吧~~今天這個就是簡單的控制8*8LED點陣亮0~F這16個數(shù)字,暫時不加左移啊~~,上移啊~~以及16*16的點陣呢~~
本文引用地址:http://2s4d.com/article/201611/321503.htm不過也就這些天都發(fā)出來吧~~
呵呵~~
8*8LED點陣顯示0~F(這里是靜態(tài)顯示)
注意:
用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 注意:這里的數(shù)據(jù)是翻轉(zhuǎn)的,因為對于紅色來說,這里上邊為列,最低位在最右邊,下邊為行,最低位在最左邊
{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
}
}
}
}
}
評論