/*
  Wokwi | questions
  not sure what the correct way to use the void

  cold frog — 11/15/24 at 9:34 PM
  how do i change elements in a table
  honestly that is just an easy google i dont know why i am asking
  ok nevermind im getting no asnwers
*/

// initialize button pins
const int BTN_PINS[] = {13, 12, 11, 10};
// initialize led pins (later when teamate makes rules)
const int LED_PINS[] = {5, 4, 3, 2};

// initialize variables that will be used later on
int strand[] = {0, 0, 0, 0};
int previous_button = 0; // placeholder
int index = 0;

void setup() {
  Serial.begin(115200);
  for (int i = 0; i < 4; i++) {
    pinMode(LED_PINS[i], OUTPUT);
    pinMode(BTN_PINS[i], INPUT_PULLUP);
  }
  Serial.println("BEGIN THE FROGGOTRON 30000");
}

int CheckButtonPressed() {
  while (true) {
    for (int i = 0; i < 4; i++) {
      if (digitalRead(BTN_PINS[i]) == LOW) {
        int returnedDigit = i + 1;
        return returnedDigit;
      }
    }
  }
}

/*
  void strandMaker() {
  for (int i = 0; i < 4; i++) {
    if (strand[i] != 0) {
      strand[i] = CheckButtonPressed();
    }
  }
  }
*/

void loop() {
  int current_button = CheckButtonPressed();
  if (previous_button != current_button)  {
    strand[index] = current_button;
    Serial.println();
    for (int i = 0; i < 4; i++) {
      Serial.print(strand[i]);
    }
    previous_button = current_button;
    index++;
    if (index >= 4) {
      index = 0;
      for (int i = 0; i < 4; i++) {
        strand[i] = 0;
      }
    }
  }
  delay(10);
}
$abcdeabcde151015202530354045505560fghijfghij