Button Chase

I am trying to figure out how to play a button game thing. I have a dozen LED buttons (4 leads, 2 for LED, 2 for push button). What I want is for the system to randomly light up one of the LEDs, then have the arduino wait until that button is pressed. Once it is pressed, a new random LED lights, and the process continues. I want to see how many buttons can be pressed in 30 seconds.

I've spent the last few ours trying to solve it, but all i can figure out is to do 1 button, everytime I try to have two I get it mixed up

Seed your random number function with an unused analog pin (lloating.) Buttons/LEDs should be an array. As buttons are pressed, the array needs to be marked (non-zero) so that if the random number routine picks an already used button, it tries again until the array is 0 then that LED is lit.

Keep count of the LEDs so that the game ends when all Buttons are pressed.


I've spent the last few ours trying to solve it

Also, show us your sketch so we can advise you.

void newOne() {

  buttonState = digitalRead(buttonPin);
  buttonState2 = digitalRead(buttonPin2);

  // compare the buttonState to its previous state
  if (buttonState != lastButtonState) {
    if (buttonState == HIGH) {
      if(buttonPushCounter % 2)
    //  Serial.println("on");
      Serial.print("number of button pushes:  ");
    else {

   digitalWrite(2, LOW);

  lastButtonState = buttonState;
 // digitalWrite(3,LOW);

  if (buttonPushCounter % 4 == 0) {
    digitalWrite(ledPin, HIGH);
  } else {
   digitalWrite(ledPin, LOW);

this was me playing with the button state, but conceptually expanding to multiple buttons caused problems