用于 LED 8x8 的程序在 Arduino Uno 中不起作用。我没有使用 pinMode() 方法。我正在使用其他方法进行规范

The program for LEDs 8x8 doesn't function in Arduino Uno. I'm not using the pinMode() method. I'm using the other method for specification

用于 LED 8x8 的程序在 Arduino Uno 中不起作用。我没有使用 pinMode() 方法为 LED 指定引脚输出。我正在使用方法“LedControl”

规格引脚:

"lc=LedControl(4,6,5,1);" 

用于设置引脚。为什么?

  1. This program compiles and executes without problems.

  2. I'm importing the library correctly.

  3. I'm using this example:

#include "LedControl.h"
/*Now we need a LedControl to work with.
pin 4 is connected to the DataIn
pin 5 is connected to the CLK
pin 6 is connected to LOAD / CS
We only have a single MAX7219 */
LedControl lc=LedControl(4,6,5,1);
/* we always wait a bit between updates of the display */
unsigned long delaytime=500;
void setup() {
  /* The MAX72XX is in power-saving mode on startup,
  we have to do a wakeup call */
  lc.shutdown(0,false);
  lc.setIntensity(0,8);
  lc.clearDisplay(0);
}
void loop() {
  lc.setIntensity(0,8);
  single();
  lc.clearDisplay(0);
}
        
/* This function will light up every Led on the matrix. The led will blink along with the row-number. row number 4 (index==3) will blink 4 times etc. */
void single() {
  for(int row=0;row<8;row++) {
    for(int col=0;col<8;col++) {
      delay(50);
      lc.setLed(0,row,col,true);
      delay(50);
      for(int i=0;i<col;i++) {
        lc.setLed(0,row,col,false);
        delay(50);
        lc.setLed(0,row,col,true);
        delay(50);
      }
    }
  }
}

LedControl 库在后台使用 pinMode 使 LED 更易于控制。当您为 LedControl 赋值时,它会自动使用 pinMode,其运行方式为 pinMode(pin, OUTPUT|INPUT).