如何修复arduino音序器总是输出

How to fix arduino sequencer always outputting

我正在尝试编写我制作的 Arduino 节奏音序器的代码,现在代码有问题,我使用 LED 作为输出。当我打开它时,所有 LED 都会在每次节拍时闪烁,即使我将音符阵列全部设置为零。我在验证或上传代码时没有看到任何错误。

const int outPins[4] = {3, 9, 10, 11};
//array of output pins

int outState = 0;
unsigned long previousMillis = 0;
//stuff for "blink without delay".
const int pot = A0;
//potentiometer/speed pin.
const int button = 7;
//button pin(not used yet).
int beats[4][16] = {{0}, {0}, {0}, {0}};
/*array of notes, first number(4) is the number of outputs.
 * second number(16) is the notes for each output. all notes should be set to "0" or off.
 */
int fast = 0;

void setup() {
  // put your setup code here, to run once:
pinMode(button, INPUT);
digitalWrite(button, HIGH);
}

void loop() {
  // put your main code here, to run repeatedly:
  fast = digitalRead(pot);
  fast = fast*100;
  
    unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= fast) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;

    // if the LED is off turn it on and vice-versa:
    if (outState == 0) {
      outState = 10;
    } else {
      outState = 0;
    }
    
    for (int j = 0; j < 16; j++)
    {
      for (int i = 0; i < 4; i++)
      {
        //for loop for every output and note.
        if (beats[i][j] = 1)
        //check if current note is on(ALL SOULD BE OFF).
        {
          analogWrite(outPins[i], outState);
          //turn on led/output.
        }
      }
    }
  }
}

if (beats[i][j] = 1) 是赋值。你想要 if (beats[i][j] == 1)