8x8 dot matrix(MAX7219) CN

아두위키 : Arduwiki
ArduWiki (토론 | 기여)님의 2025년 3월 20일 (목) 20:39 판 (새 문서: {{#seo:|title=Arduino维基:Arduino 8x8点阵(8x8 dot matrix, MAX7219)|title_mode=append|keywords=Arduino, 信息科学, 创客学习, 性能评估, 8x8点阵, Arduino项目, 毕业设计项目, Arduino示例代码|description=介绍如何使用Arduino控制8x8点阵(基本信息、电路、示例代码)。可用于信息科学和创客课程。8x8点阵(8x8 dot matrix, MAX7219)}} center|class=coders100 将LED排列成...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

将LED排列成8x8网格的器件。

使用MAX7219,除电源引脚外只需3个引脚即可控制。

可以连接多个点阵模块一起使用。


规格

  • 工作电压:5V
  • 工作电流:320mA ~ 2A


所需硬件

  • 点阵模块
  • Arduino


连接

  • 运行示例代码的连接
Dot matrix Arduino
VCC 5V
GND GND
DIN D12
CS D11
CLK D10


  • 使用两个或更多点阵时的连接
Left Dot Matrix Right Dot Matrix
VCC VCC
GND GND
DOUT DIN
CLK CLK
CS CS

Library

示例代码

#include "LedControl.h" // Library call for using the dot matrix

#define dataIn 12   // Use pin 12 for DIN
#define cs 11       // Use pin 11 for CS
#define clk 10      // Use pin 10 for CLK

LedControl lc = LedControl(dataIn, clk, cs, 1); // LedControl('DIN pin number', 'CLK pin number', 'CS pin number', 'number of dot matrices')

void setup() {
  lc.shutdown(0, false);    // Code to wake up the dot matrix. shutdown('address of the dot matrix to specify', 'false: wake up')
  lc.setIntensity(0, 8);    // Set brightness. setIntensity('address of the dot matrix to specify','brightness value (0~15)')
  lc.clearDisplay(0);       // Initialization before use. clearDisplay('address of the dot matrix to specify')
}

void loop() // Blink the dot matrix for 1 second.
{
  // Turn on the LEDs of the dot matrix.
  for (int row = 0; row < 8; row++)
  {
    for (int col = 0; col < 8; col++)
    {
      lc.setLed(0, col, row, true);
    }
  }
  delay(1000);
  // Turn off the LEDs of the dot matrix.
  for (int row = 0; row < 8; row++)
  {
    for (int col = 0; col < 8; col++)
    {
      lc.setLed(0, col, row, false);
    }
  }
  delay(1000);
}