0

(arduino 新手)下面的代码有什么问题,我可以看到端口 9 和 10 同时闪烁,后来端口 11 闪烁。

当我尝试使用端口 3、5、6 时,它工作正常。我只有 9,10,11 端口有问题

const int col[3] = {9,10,11};

void setup() {
  for (int thisPin = 0; thisPin < 3; thisPin++) {
    pinMode(col[thisPin], OUTPUT); 
  }
}

void loop() {
  refreshScreen();
}  

void refreshScreen() {
  for (int index = 0; index < 3; index++) {
    digitalWrite(col[index], HIGH);
    delay(300);
    digitalWrite(col[index], LOW);
  }
}

我的 arduino 有缺陷还是 PWM 端口的行为是这样的!!!?

4

1 回答 1

0

PWM pins work the same as any other using digitalWrite(). It looks to me like the code should work. Is it possible that you're somehow shorting the outputs of 9 and 10 together? If not, sounds to me like pins 9 and 10 are defective.

于 2014-07-18T16:54:41.020 回答