An Amusement Machine using LEDs

I guess another variable to declare?

well later we need to change spinCount as an array and not a simple variable so we keep the poistion of each wheel between successive games.

Study this and compare it with what I told you to do.

//multi-array of 3 reels of 25 symbols made up of 10 different tokens
byte symbols[3][25] = {
  {2, 3, 2, 4, 5, 6, 3, 2, 7, 2, 8, 9, 3, 4, 5, 2, 3, 2, 10, 2, 11, 2, 3, 9, 5 },
  {10, 4, 9, 2, 3, 4, 9, 5, 6, 4, 9, 7, 8, 4, 9, 11, 9, 3, 5, 9, 5, 3, 2, 9, 4 },
  {10, 4, 9, 2, 3, 4, 9, 5, 6, 4, 9, 7, 8, 4, 9, 11, 9, 3, 5, 9, 5, 3, 2, 9, 4 }
};

byte wheel[3] = {0, 0, 0}; //wheel array for storing the stop token for three reel spins


void setup() {
  for (int i = 2; i < 12; i++) { // declare pin numbers for 10 symbols
    pinMode(i, OUTPUT); //declare pins as outputs
  }
  pinMode(15, INPUT_PULLUP); //declare pin 15 as an input with 5V pullup resitor
  Serial.begin(9600); // needs to be in setup and not loop
}

void loop() {
  // int j = wheel[0]; this is not needed the declaration is in the for loop
 // int i = spin();  this is not needed the declaration is in the for loop
 
  for (int j = 0; j < 3 ; j++ ) {  //calling up 3 wheels indexing through matrix rows
     // you need to call spin here and tell it what wheel it is on
     wheel[j] = spin(j); // we are passing a paramater to spin so we have to change the spin function to cope with this
    for (int i = 0; i < 3; i ++) { // flashing symbol passed up (back not up) from spin function 
      flash(200, 200, wheel[j]);
    }
  }

  while (1) { } // stop, press reset to start
}
// flash function calls up each token LED & turns on then off

void flash( int onTime, int offTime, byte token)  {
  digitalWrite(token, HIGH); // will turn on the LED
  delay(onTime); // so you can see it
  digitalWrite(token, LOW); // will turn off the LED
  delay(offTime); // so you can see it off
}

int spin(int wheelToUse) { // need to tell spin to accept a symbol
  // loop along 25 smbol row in array
  static int spinCount = 0;

  // waiting...
  while (digitalRead(15) == HIGH) { } // do nothing until the switch is moved
  // spin action starts here
  while (digitalRead(15) == LOW) { //checking if input remains high before advancing count

    spinCount += 1;

    if (spinCount == 25) spinCount = 0; //Checking if variable spinCount needs wrapping around
    flash(600, 200, symbols[wheelToUse][spinCount]); // quick flash for each moving symbol

    Serial.print(spinCount);
    if (spinCount == 0) Serial.println(" "); //start a new line on printout
  }
//  int. stopSymbol = symbols[0][spinCount] // no need to give it its own variable 
  return symbols[wheelToUse][spinCount]; // send back the symbol/token it landed on
}