美文网首页
Arduino Dot Matrix Module

Arduino Dot Matrix Module

作者: 范女青 | 来源:发表于2018-09-21 08:11 被阅读0次

The dot matrix is pre-connected to Arduino board. Two pins (pin number 20 and 21) – (I2C) are used and 5V power should be supplied.
The dot matrix module displays 8 X 8 dot LED that can display strings or pictorial symbols.

[LedControl 函式庫]
• 建立一個新的控制:LedControl(int dataPin, int clkPin, int csPin, int numDevices);
int dataPin : Arduino 資料輸出的 Pin
int clockPin : 時鐘 Clock Pin
int csPin : 當資料被送出時選擇的設備 device
int numDevices : 最多有多少個設備要被控制

• 設定進入省電模式:shutdown(int addr, bool b);
int addr : 控制顯示的位址
boolean b : 設定為 true,設備進入電力中斷模式,設定為 false 為正常模式

• 設定顯示亮度:setIntensity(int addr, int intensity);
int addr : 控制顯示的位址
int intensity : 顯示器的亮度,介於 0(最暗) 及15(最亮) 之間

• 將所有LED設定成不顯示:clearDisplay(int addr);
int addr : 控制顯示的位址

• 設定單一個LED 的亮或滅狀態:setLed(int addr, int row, int col, boolean state);
addr : 顯示的位址
row : Led的列數 (0..7)
col : Led的欄數 (0..7)
state : 設定為 true,Led為亮,設定為 false,則關閉 Led 顯示

• 使用8bits顯示指定列的8個LED 亮或滅狀態:setRow(int addr, int row, byte value);
addr : 顯示的位址
row : 列的編號 (0..7)
value : 8 bits 來顯示該列的LED是否為亮,1為亮,0為暗

• 使用8bits顯示指定欄的8個LED 亮或滅狀態:setColumn(int addr, int col, byte value);
addr : 顯示的位址
col : 欄的編號 (0..7)
value : 8 bits 來顯示該欄的LED是否為亮,1為亮,0為暗

• 在7段顯示器顯示一個十六進位數字: setDigit(int addr, int digit, byte value, boolean dp);
addr : 顯示的位址
digit : 顯示字元的位置 (0..7)
value : 顯示的數字 (0x00..0x0F)
dp : 設定小數點

• 在7段顯示器顯示一個字元: setChar(int addr, int digit, char value, boolean dp);
addr : 顯示的位址
digit : 顯示字元的位置 (0..7)
value : 顯示的字元,僅可顯示'0','1','2','3','4','5','6','7','8','9','0',
'A','b','c','d','E','F','H','L','P','.','-','_',' '
dp : 設定小數點

#include "RL_DotMatrix.h"
DotMatrix dm = DotMatrix(); 
void setup()
{
  // the DotMatrix is in power-saving mode on startup. do a wakeup call     
  dm.shutdown(0,false);
  // set medium brightness 
  dm.setIntensity(0,2); 
  dm.clearDisplay(0);
}
 
// displays the words 'Arduino' 
void writeArduinoOnMatrix()
{
  dm.clearDisplay(0);
/* here is the data for the characters */
byte a[5]={B01111110,B10001000,B10001000,B10001000,B01111110}; 
byte r[5]={B00111110,B00010000,B00100000,B00100000,B00010000}; 
byte d[5]={B00011100,B00100010,B00100010,B00010010,B11111110}; 
byte u[5]={B00111100,B00000010,B00000010,B00000100,B00111110}; 
byte i[5]={B00000000,B00100010,B10111110,B00000010,B00000000}; 
byte n[5]={B00111110,B00010000,B00100000,B00100000,B00011110}; 
byte o[5]={B00011100,B00100010,B00100010,B00100010,B00011100};

/* now display them one by one with a small delay */ 
dm.setRow(0,0,a[4]);
dm.setRow(0,1,a[3]);
dm.setRow(0,2,a[2]);
dm.setRow(0,3,a[1]);
dm.setRow(0,4,a[0]); 
delay(1000); 
dm.setRow(0,0,r[4]);
dm.setRow(0,1,r[3]);
dm.setRow(0,2,r[2]);
dm.setRow(0,3,r[1]);
dm.setRow(0,4,r[0]); 
delay(1000); 
dm.setRow(0,0,d[4]);
dm.setRow(0,1,d[3]);
dm.setRow(0,2,d[2]);
dm.setRow(0,3,d[1]);
dm.setRow(0,4,d[0]); 
delay(1000); 
dm.setRow(0,0,u[4]);
dm.setRow(0,1,u[3]);
dm.setRow(0,2,u[2]);
dm.setRow(0,3,u[1]);
dm.setRow(0,4,u[0]); 
delay(1000); 
dm.setRow(0,0,i[4]);
dm.setRow(0,1,i[3]);
dm.setRow(0,2,i[2]);
dm.setRow(0,3,i[1]);
dm.setRow(0,4,i[0]); 
delay(1000); 
dm.setRow(0,0,n[4]);
dm.setRow(0,1,n[3]);
dm.setRow(0,2,n[2]);
dm.setRow(0,3,n[1]);
dm.setRow(0,4,n[0]); 
delay(1000); 
dm.setRow(0,0,o[4]);
dm.setRow(0,1,o[3]);
dm.setRow(0,2,o[2]);
dm.setRow(0,3,o[1]);
dm.setRow(0,4,o[0]); 
delay(1000); 
dm.setRow(0,0,0);
dm.setRow(0,1,0);
dm.setRow(0,2,0);
dm.setRow(0,3,0);
dm.setRow(0,4,0); 
delay(1000);
}

// this will light up every Led on the matrix 
void single()
{
 dm.clearDisplay(0); 
  for(int row=0;row<8;row++)
  {
    for(int col=0;col<8;col++)
    {
      dm.setLed(0,row,col,true); 
      delay(50);
    }
  }
}

void loop()
{
  writeArduinoOnMatrix(); 
  single();
}

引用:http://atceiling.blogspot.com/2017/03/arduinomax7219-8x8-led-matrix.html

相关文章

网友评论

      本文标题:Arduino Dot Matrix Module

      本文链接:https://www.haomeiwen.com/subject/jrmgnftx.html