首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >LED 8x8的程序在Arduino Uno中不起作用。我不使用pinMode()方法。我正在用另一种方法来说明

LED 8x8的程序在Arduino Uno中不起作用。我不使用pinMode()方法。我正在用另一种方法来说明
EN

Stack Overflow用户
提问于 2015-08-22 22:33:58
回答 1查看 232关注 0票数 0

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

规格销:

代码语言:javascript
复制
"lc=LedControl(4,6,5,1);" 

用于设置引脚的。为什么?

  1. 这个程序编译和执行没有问题。
  2. 我是正确导入图书馆的。
  3. 我用这个例子:
代码语言:javascript
复制
#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);
      }
    }
  }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-08-22 22:58:29

LedControl库在后台使用pinMode使LED更易于控制。当您将值赋给LedControl时,它会自动使用pinMode,它作为pinMode(pin, OUTPUT|INPUT)操作。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32161434

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档