Buzz wire game arduino

Hi, We are 3 students who have to make a buzz wire game for a project for our university. We are creating a buzz wire game, with a couple of extra adjustement. Like 2 moving servo's, a timer that shows how much time is left and a buzzer play a song, so it is working on your nerves.

So it includes a basic buzz wire game, with a theard and a stick. Two servo's are attached to the end of the wire, to create a random movent at random times. The first buzzer is too indicate you touched the thread, so it only has to make a short noise. The second buzzer is used to play a song while the game starts. The first led is to indicate the game is on, you do so by pressing on the first button. The second button is to start the game. When the game starts the song has to play, the timer has to start going off and the buzzer has to go of whenever you touch the wire.

And this is the set up in the arduino board

This is what we have so far, but is working far from perfect.

void setup() {

 Serial.begin(9600); //Start verbinding met de pc

  pinMode(deuntje, OUTPUT);
  pinMode(buzzer, OUTPUT);
  pinMode(led, OUTPUT);
  pinMode(timerled, OUTPUT);
  pinMode(servo1, OUTPUT);
  pinMode(servo2, OUTPUT); 
  pinMode(drukknop1, INPUT);
  pinMode(drukknop2, INPUT);
  pinMode(A3, INPUT_PULLUP);

// Led
  pixels.begin();           // Start verbinding met de led (Dit heeft een vaste snelheid en moeten we dus niet opgeven)
  pixels.clear();           // Zet alle leds uit
  pixels.setBrightness(50); // Om uw ogen wat te besparen dimmen we de maximale helderheid van de leds

// Timerled
  pixels1.begin();           // Start verbinding met de led (Dit heeft een vaste snelheid en moeten we dus niet opgeven)
  pixels1.clear();           // Zet alle leds uit
  pixels1.setBrightness(50); // Om uw ogen wat te besparen dimmen we de maximale helderheid van de leds


// Servomotor
  servomotor1.attach(5); //Verbind de servomoter met pin 5
  servomotor2.attach(3); //Verbind de servomoter met pin 3
}

void loop() {

//Aanzetten spel
  while(digitalRead(drukknop1)== false){};
  drukknop1waarde = digitalRead(drukknop1);    // waarde drukknop om het spel aan te zetten wordt uitlezen
  Serial.println(drukknop1waarde);             // print waarde drukknop1
  delay(100); 
  
  if (drukknop1waarde == 1 && druk_status == false) {        // gaat het ledje aan oom aan te tonen dat het spel aan staat
    //start
  kleur = pixels.Color(0,255,0);    //Maak een kleur aan en sla deze op in variabele kleur
  pixels.setPixelColor(0, kleur);   //Stuur deze kleur door naar de eerste led
  pixels.show();                    //Stuur signaal naar de led dat alle leds de kleur mogen tonen
  delay(5);
  druk_status = true;
  } else if(drukknop1waarde == 1 && druk_status == true){
    //stop
      kleur = pixels.Color(0,0,0);    //Maak een kleur aan en sla deze op in variabele kleur
      pixels.clear();
      pixels.show();
      delay(5);
      druk_status = false;
  }

//Starten spel
  while(digitalRead(drukknop2)== false){};
  drukknop2waarde = digitalRead(drukknop2);    // waarde drukknop om het spel te starten wordt uitlezen
  Serial.println(drukknop2waarde);             // print waarde drukknop2
  delay(100); 
  
 if (drukknop2waarde == 1 && druk_status1 == false) {        //Buzzer voor liedje gaat aan om aan te tonen dat het spel gestart is
    //start
    tone(buzzer, 1000);
  druk_status1 = true;
  } else if(drukknop2waarde == 1 && druk_status1 == true){
    //stop
    noTone(buzzer);
      druk_status1 = false;
 }
//At random bewegen servomtor1 op een random tijd
if (drukknop2waarde == 1 && druk_status == false) { 
 for (pos = 0; pos <= 180; pos += 180){
  servomotor1.write(pos);
  delay(500);
 }
 for (pos = 180; pos >= 0; pos -= 180){
  servomotor1.write(pos);
  delay(500);
 }

 delay(random(500, 5000));
 druk_status1 = true;
 
}else if(drukknop2waarde == 1 && druk_status1 == true){
    //stop
    
     druk_status1 = false;
 }


//At random bewegen servomto2 op een random tijd
if (drukknop2waarde == 1 && druk_status == false) { 
 for (pos = 0; pos <= 180; pos += 180){
  servomotor2.write(pos);
  delay(500);
 }
 for (pos = 180; pos >= 0; pos -= 180){
  servomotor2.write(pos);
  delay(500);
 }

 delay(random(500, 5000));
 druk_status1 = true;
 
}else if(drukknop2waarde == 1 && druk_status1 == true){
    //stop
    
     druk_status1 = false;
 }

//Timer
  kleur1 = pixels1.Color(0,255,0);
  pixels1.fill(kleur);
  pixels1.show();
  delay(1500);
  for (int i=0; i < aantal_timerleds; i++) {
  kleur1 = pixels1.Color(0,0,0);    // Maak een kleur aan en sla deze op in variabele kleur
  pixels1.setPixelColor(i, kleur1);   // Stuur deze kleur door naar de eerste led
  pixels1.show();     
  delay(1500);
 
  }

}

Our questions now are:

  1. We have to replace the delay () with millis () but we are not sure how?
  2. We have to write a code so that the game only can start when start button is pushed.
  3. The game has to reset when the timer is done.
  4. When de start button is pushed in to set up the game and you want to shut off the game you have to push the button again, and than the hole game has to go out. But this isn't working either.

If you have other tips or tricks or know how to help us your more than welcome because we are really desprate.

Kind regards,
Three really stressed students that know very little about ardiuno

And we know even less about a buzz wire game.

Your code is incomplete. It is missing library includes and variable declaration at the least. Kudos for using code tags, though.

You will need to tell us what that means. My crystal ball is out for an oil change.

Here is a start for that. Non-blocking timing tutorials:
Blink without delay().
Beginner's guide to millis().
Several things at a time.

State change detection is a good way to sense when a button input has changed from not pressed to pressed so that you can take an action only one time instead of as long as the button is pressed. The linked Arduino tutorial uses active high switches wired to Vcc with an external pulldown. My state change for active low inputs uses switches wired to ground and the internal pullup which is the more professionally accepted way to wire switches. The tutorial has example code and how to wire the switches.

To be of more help, a schematic would be helpful.

How are the servos powered?