LED點(diǎn)陣,相信肯定知道單片機(jī)的人都該知道這個(gè),我也就是一步一步發(fā)吧~~今天這個(gè)就是簡(jiǎn)單的控制8*8LED點(diǎn)陣亮0~F這16個(gè)數(shù)字,暫時(shí)不加左移啊~~,上移啊~~以及16*16的點(diǎn)陣呢~~
本文引用地址:http://m.butianyuan.cn/article/201611/321503.htm不過(guò)也就這些天都發(fā)出來(lái)吧~~
呵呵~~
8*8LED點(diǎn)陣顯示0~F(這里是靜態(tài)顯示)
注意:
用Proteus仿真開(kāi)始還真的不知道那個(gè)是行,那個(gè)是列~~
還得浪費(fèi)我時(shí)間一點(diǎn)點(diǎn)看人家別人的東東~~
1)紅色LED上邊為列,下邊為行(其它顏色的正好相反,上為行,下為列~~)
2)對(duì)于紅色來(lái)說(shuō),上邊的列最低位在最右邊;下邊的行最低位也是恰好相反,在最左邊(一會(huì)看圖就知道了,我的就寫(xiě)反了~~正好可以反過(guò)來(lái)看了~~)
基本上就這么兩點(diǎn)的注意事項(xiàng)~~
然后就是程序了:
LED.c
//------------------------------------------------------------------------------
//以前還真的沒(méi)仿真過(guò)LED點(diǎn)陣,今天正好沒(méi)事情做~~
//注意一點(diǎn)吧,紅色的上為列,下為行,其它顏色正好相反~~(前提是我也沒(méi)記錯(cuò)的情況下~~呵呵,剛試驗(yàn)了一下,對(duì)的~~)
#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)的,因?yàn)閷?duì)于紅色來(lái)說(shuō),這里上邊為列,最低位在最右邊,下邊為行,最低位在最左邊
{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);//延時(shí)100ms
}
}
}
}
}
評(píng)論