Ardino基础教程 25_8X8LED点阵
實驗二十五:8X8LED點陣
點陣實驗另一版本代碼參考如下鏈接下載:ArduinoCode25-8X8LED點陣num.ino
點陣在我們生活中很常見,很多都有用到他,比如LED 廣告顯示屏,電梯顯示樓層。公交車報站,等等,,,數不勝數。廢話不多說,趕緊學習吧。
1、8X8LED點陣原理圖
2、8X8LED點陣實物圖
圖為8×8點陣LED外觀及引腳圖,其等效電路如圖所示,只要其對應的X、Y軸順向偏壓,即可使LED發亮。例如如果想使左上角LED點亮,則Y0=1,X0=0即可。應用時限流電阻可以放在X軸或Y軸
3、8X8LED點陣掃描方式
LED一般采用掃描式顯示,實際運用分為三種方式
16×64=1024Hz,周期小于1ms即可。若使用第二和第三種方式,則頻率必須大于16×8=128Hz,周期小于7.8ms即可符合視覺暫留要求。此外一次驅動一列或一行(8顆LED)時需外加驅動電路提高電流,否則LED亮度會不足。
4、8X8LED點陣應用舉例
點陣內部結構及外形如下,8X8點陣共由64個發光二極管組成,且每個發光二極管是放置在行線和列線的交叉點上,當對應的某一行置1電平,某一列置0電平,則相應的二極管就亮;如要將第一個點點亮,則9腳接高電平13腳接低電平,則第一個點就亮了;如果要將第一行點亮,則第9腳要接高電平,而(13、3、4、10、6、11、15、16)這些引腳接低電平,那么第一行就會點亮;如要將第一列點亮,則第13腳接低電平,而(9、14、8、12、1、7、2、5)接高電平,那么第一列就會點亮。
一般我們使用點陣顯示漢字是用的1616的點陣宋體字庫,所謂1616,是每一個漢字在縱、橫各16點的區域內顯示的。也就是說得用四個88點陣組合成一個1616的點陣。如下圖所示,要顯示“你”則相應的點就要點亮,由于我們的點陣在列線上是低電平有效,而在行線上是高電平有效,所以要顯示“你”字的話,它的位代碼信息要取反,即所有列(13~16腳)送(1111011101111111,0xF7,0x7F),而第一行(9腳)送1信號,然后第一行送0。再送第二行要顯示的數據(13~16腳)送(1111011101111111,0xF7,0x7F),而第二行(14腳)送1信號。依此類推,只要每行數據顯示時間間隔夠短,利用人眼的視覺暫停作用,這樣送16次數據掃描完16行后就會看到一個“你”字;第二種送數據的方法是字模信號送到行線上再掃描列線也是同樣的道理。同樣以“你”字來說明,16行(9、14、8、12、1、7、2、5)上送(0000000000000000,0x00,0x00)而第一列(13腳)送、“0”。同理掃描第二列。當行線上送了16次數據而列線掃描了16次后一個“你”字也就顯示出來了。
因此,形成的列代碼為 00H,00H,3EH,41H,41H,3EH,00H,00H;只要把這些代碼分別依次送到相應的列線上面,即可實現“0”的數字顯示。
點亮8X8點陣LED的一個LED如下:
這個是顯示“0”的程序代碼。
//定義了一個數組,用來存放“0”字的字模
unsigned char Text[]={0x00,0x1c,0x22,0x22,0x22,0x22,0x22,0x1c};
void Draw_point(unsigned char x,unsigned char y)//畫點函數
{
clear_();
digitalWrite(x+2, HIGH);
digitalWrite(y+10, LOW);
delay(1);
}
void show_num(void)//顯示函數,最終還是調用了畫點函數。
{
unsigned char i,j,data;
for(i=0;i<8;i++)
{
data=Text[i];
for(j=0;j<8;j++)
{
if(data & 0x01)Draw_point(j,i);
data>>=1;
}
}
}
void setup(){
int i = 0 ;
for(i=2;i<18;i++)
{
pinMode(i, OUTPUT);
}
clear_();
}
void loop()
{
show_num();
}
void clear_(void)//清除屏幕
{
for(int i=2;i<10;i++)
digitalWrite(i, LOW);
for(int i=0;i<8;i++)
digitalWrite(i+10, HIGH);
}
實驗截圖
Arduino 8x8點陣 //注意引腳圖是反起看的,當原件插上去的時候,左右交換。
連線對應關系:
要在其中一列加上1K或220歐姆限流電阻
Arduino 8x8點陣
2 ----------------------0 //行選0
3 ----------------------1 //行選1
4 ----------------------2 //行選2
5 ----------------------3 //行選3
6 ----------------------4 //行選4
7 ----------------------5 //行選5
8 ---------------------6 //行選6
9 ---------------------7 //行選7
Arduino 8x8點陣
10 ---------------------A //列選A
11 ---------------------B //列選B
12 ---------------------C //列選C
13 ---------------------D //列選D
14 ---------------------E //列選E
15 ---------------------F //列選F
16 ---------------------G //列選G
17 ---------------------H //列選H
程序代碼
//the pin to control ROW const int row1 = 2; // the number of the row pin 9 const int row2 = 3; // the number of the row pin 14 const int row3 = 4; // the number of the row pin 8 const int row4 = 5; // the number of the row pin 12 const int row5 = 6; // the number of the row pin 1 const int row6 = 7; // the number of the row pin 7 const int row7 = 8; // the number of the row pin 2 const int row8 = 9; // the number of the row pin 5 //the pin to control COl const int col1 = 10; // the number of the col pin 13 const int col2 = 11; // the number of the col pin 3 const int col3 = 12; // the number of the col pin 4 const int col4 = 13; // the number of the col pin 10 const int col5 = 14; // the number of the col pin 6 const int col6 = 15; // the number of the col pin 11 const int col7 = 16; // the number of the col pin 15 const int col8 = 17; // the number of the col pin 16 void setup(){ int i = 0 ; for(i=2;i<18;i++) { pinMode(i, OUTPUT); } pinMode(row5, OUTPUT); pinMode(row6, OUTPUT); pinMode(row7, OUTPUT); pinMode(row8, OUTPUT); for(i=2;i<18;i++) { digitalWrite(i, LOW); } for(i=2;i<18;i++) { digitalWrite(row5, LOW); } } void loop(){ int i; for(i=2;i<10;i++) {digitalWrite(i, HIGH);delay(200);clear_(); } //delay(1000); } void clear_(void) {for(int i=2;i<18;i++)digitalWrite(i, LOW); } //the pin to control ROW const int row1 = 2; // the number of the row pin 9 const int row2 = 3; // the number of the row pin 14 const int row3 = 4; // the number of the row pin 8 const int row4 = 5; // the number of the row pin 12 const int row5 = 6; // the number of the row pin 1 const int row6 = 7; // the number of the row pin 7 const int row7 = 8; // the number of the row pin 2 const int row8 = 9; // the number of the row pin 5 //the pin to control COl const int col1 = 10; // the number of the col pin 13 const int col2 = 11; // the number of the col pin 3 const int col3 = 12; // the number of the col pin 4 const int col4 = 13; // the number of the col pin 10 const int col5 = 14; // the number of the col pin 6 const int col6 = 15; // the number of the col pin 11 const int col7 = 16; // the number of the col pin 15 const int col8 = 17; // the number of the col pin 16 unsigned char Text[]={0x00,0x1c,0x22,0x22,0x22,0x22,0x22,0x1c}; void Draw_point(unsigned char x,unsigned char y) {clear_();digitalWrite(x+2, HIGH);digitalWrite(y+10, LOW);delay(1); } void show_num(void) {unsigned char i,j,data;for(i=0;i<8;i++){data=Text[i];for(j=0;j<8;j++){if(data & 0x01)Draw_point(j,i);data>>=1;} } } void setup(){ int i = 0 ; for(i=2;i<18;i++) { pinMode(i, OUTPUT); } clear_(); } void loop() { show_num(); } void clear_(void) {for(int i=2;i<10;i++)digitalWrite(i, LOW);for(int i=0;i<8;i++)digitalWrite(i+10, HIGH); }總結
以上是生活随笔為你收集整理的Ardino基础教程 25_8X8LED点阵的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Ardino基础教程 24_RGB全彩L
- 下一篇: 《深度学习的数学》二刷总结