Introduction: Throwing Knives at a Spinning Person

Throw a (hypothetical) knife at a spinning person.

While a disk turns around its axis (= DC motor), a light sensor detects when you can throw the knife by pushing the button.
* Cardboard removes light -> you can't throw -> person doesnt get hurt
* Throwing the knife = servo motor rotates 150° and back.

There are also leds that dance on the beat of the Pirates of the Caribbean theme song.

You can download a 10 second video below to see how it works.
(You can't here the song, because there's too much noise.
To hear the song, click the link. Pirates of the Caribbean theme song ARDUINO )

Supplies

* Arduino Uno + cable to connect to PC + Arduino IDE (program)
* Jumper wires
* Pushbutton + 10K resistor
* 5 Leds
* DC motor + NPN transistor + Diode
* Arduino speaker
* 7 560 Ohm resistors

Step 1: Build the Circuit

I built it using a small breadboard, i recommend using a bigger one ;)

You can choose how many LEDs you want to use.
I used 5 LEDs.
If you don't, you will have to change the code.
I'll explain that below.
Idem for changing the song. Then you will need the correct order and length of the notes.

Step 2: Code

// Buzzer song (in this case: Pirates of the Caribbean)
/* If you want to change the song, you'll need to know the correct order and length of the notes and replace them down below at the right place. */
            const int buzzer = 6;
            
            // Change to 0.5 for a slower version of the song, 1.25 for a faster version
            const float songSpeed = 1.0;
            
            // Defining frequency of each music note (you can add more)
            #define NOTE_C4 262
            #define NOTE_D4 294
            #define NOTE_E4 330
            #define NOTE_F4 349
            #define NOTE_G4 392
            #define NOTE_A4 440
            #define NOTE_B4 494
            #define NOTE_C5 523
            #define NOTE_D5 587
            #define NOTE_E5 659
            #define NOTE_F5 698
            #define NOTE_G5 784
            #define NOTE_A5 880
            #define NOTE_B5 988
            
            // Music notes of the song, 0 is a rest/pulse
            int notes[] = {
                NOTE_E4, NOTE_G4, NOTE_A4, NOTE_A4, 0,
                NOTE_A4, NOTE_B4, NOTE_C5, NOTE_C5, 0,
                NOTE_C5, NOTE_D5, NOTE_B4, NOTE_B4, 0,
                NOTE_A4, NOTE_G4, NOTE_A4, 0,
            
                NOTE_E4, NOTE_G4, NOTE_A4, NOTE_A4, 0,
                NOTE_A4, NOTE_B4, NOTE_C5, NOTE_C5, 0,
                NOTE_C5, NOTE_D5, NOTE_B4, NOTE_B4, 0,
                NOTE_A4, NOTE_G4, NOTE_A4, 0,
            
                NOTE_E4, NOTE_G4, NOTE_A4, NOTE_A4, 0,
                NOTE_A4, NOTE_C5, NOTE_D5, NOTE_D5, 0,
                NOTE_D5, NOTE_E5, NOTE_F5, NOTE_F5, 0,
                NOTE_E5, NOTE_D5, NOTE_E5, NOTE_A4, 0,
            
                NOTE_A4, NOTE_B4, NOTE_C5, NOTE_C5, 0,
                NOTE_D5, NOTE_E5, NOTE_A4, 0,
                NOTE_A4, NOTE_C5, NOTE_B4, NOTE_B4, 0,
                NOTE_C5, NOTE_A4, NOTE_B4, 0,
            
                NOTE_A4, NOTE_A4,
                //Repeat of first part
                NOTE_A4, NOTE_B4, NOTE_C5, NOTE_C5, 0,
                NOTE_C5, NOTE_D5, NOTE_B4, NOTE_B4, 0,
                NOTE_A4, NOTE_G4, NOTE_A4, 0,
            
                NOTE_E4, NOTE_G4, NOTE_A4, NOTE_A4, 0,
                NOTE_A4, NOTE_B4, NOTE_C5, NOTE_C5, 0,
                NOTE_C5, NOTE_D5, NOTE_B4, NOTE_B4, 0,
                NOTE_A4, NOTE_G4, NOTE_A4, 0,
            
                NOTE_E4, NOTE_G4, NOTE_A4, NOTE_A4, 0,
                NOTE_A4, NOTE_C5, NOTE_D5, NOTE_D5, 0,
                NOTE_D5, NOTE_E5, NOTE_F5, NOTE_F5, 0,
                NOTE_E5, NOTE_D5, NOTE_E5, NOTE_A4, 0,
            
                NOTE_A4, NOTE_B4, NOTE_C5, NOTE_C5, 0,
                NOTE_D5, NOTE_E5, NOTE_A4, 0,
                NOTE_A4, NOTE_C5, NOTE_B4, NOTE_B4, 0,
                NOTE_C5, NOTE_A4, NOTE_B4, 0,
                //End of Repeat
            
                NOTE_E5, 0, 0, NOTE_F5, 0, 0,
                NOTE_E5, NOTE_E5, 0, NOTE_G5, 0, NOTE_E5, NOTE_D5, 0, 0,
                NOTE_D5, 0, 0, NOTE_C5, 0, 0,
                NOTE_B4, NOTE_C5, 0, NOTE_B4, 0, NOTE_A4,
            
                NOTE_E5, 0, 0, NOTE_F5, 0, 0,
                NOTE_E5, NOTE_E5, 0, NOTE_G5, 0, NOTE_E5, NOTE_D5, 0, 0,
                NOTE_D5, 0, 0, NOTE_C5, 0, 0,
                NOTE_B4, NOTE_C5, 0, NOTE_B4, 0, NOTE_A4};
            
            // Durations (in ms) of each music note of the song
            // Quarter Note is 250 ms when songSpeed = 1.0
            int durations[] = {
                125, 125, 250, 125, 125,
                125, 125, 250, 125, 125,
                125, 125, 250, 125, 125,
                125, 125, 375, 125,
            
                125, 125, 250, 125, 125,
                125, 125, 250, 125, 125,
                125, 125, 250, 125, 125,
                125, 125, 375, 125,
            
                125, 125, 250, 125, 125,
                125, 125, 250, 125, 125,
                125, 125, 250, 125, 125,
                125, 125, 125, 250, 125,
            
                125, 125, 250, 125, 125,
                250, 125, 250, 125,
                125, 125, 250, 125, 125,
                125, 125, 375, 375,
            
                250, 125,
                //Rpeat of First Part
                125, 125, 250, 125, 125,
                125, 125, 250, 125, 125,
                125, 125, 375, 125,
            
                125, 125, 250, 125, 125,
                125, 125, 250, 125, 125,
                125, 125, 250, 125, 125,
                125, 125, 375, 125,
            
                125, 125, 250, 125, 125,
                125, 125, 250, 125, 125,
                125, 125, 250, 125, 125,
                125, 125, 125, 250, 125,
            
                125, 125, 250, 125, 125,
                250, 125, 250, 125,
                125, 125, 250, 125, 125,
                125, 125, 375, 375,
                //End of Repeat
            
                250, 125, 375, 250, 125, 375,
                125, 125, 125, 125, 125, 125, 125, 125, 375,
                250, 125, 375, 250, 125, 375,
                125, 125, 125, 125, 125, 500,
            
                250, 125, 375, 250, 125, 375,
                125, 125, 125, 125, 125, 125, 125, 125, 375,
                250, 125, 375, 250, 125, 375,
                125, 125, 125, 125, 125, 500};

// define leds /* Add or delete LEDs if you want. Then you'll have to add/delete LED outputs down below and change the code of the LEDs in the void loop. */
                #define led_1 8
                #define led_2 9
                #define led_3 10
                #define led_4 11
                #define led_5 12

// servo motor + push button /* If you want to change the angle, replace the 150 twice by an other number (cf. HERE) */
                #include <Servo.h>
                
                Servo myservo;  // create servo object to control a servo
                #define servoPin 3 //~
                #define pushButtonPin 2 
                
                int angle =0;    // initial angle  for servo (beteen 1 and 179)
                int angleStep =150;  		// HERE
                const int minAngle = 0;
                const int maxAngle = 150;	// HERE
                
                const int type =1;//1 = van min Angle naar maxAngle en trug, 2= omgekeerd
                
                int buttonPushed =0;

//light sensor
                int lightSensorPin = A0;
                int analogValue = 0;

//DC motor
                const int motorPin = 5; 


                

void setup()
{
// DC motor
                pinMode(motorPin,OUTPUT);
                
                Serial.begin(9600);          //  setup serial 
// servo motor
                myservo.attach(servoPin);  // attaches the servo on pin 3 to the servo object
                pinMode(pushButtonPin,INPUT_PULLUP);
                 myservo.write(angle);//initial position

// leds (add or delete led outputs according to the amount of LEDs you want)
                 pinMode(led_1,OUTPUT);
                  pinMode(led_2,OUTPUT);
                   pinMode(led_3,OUTPUT);
                    pinMode(led_4,OUTPUT);
                      pinMode(led_5,OUTPUT);
}



void loop()
{
//DC motor /* Change the speed to the speed you desire.*/
                analogWrite(motorPin,55);



// music 
               const int totalNotes = sizeof(notes) / sizeof(int);
                // Loop through each note
                for (int i = 0; i < totalNotes; i++)
                {
                  const int currentNote = notes[i];
                  float wait = durations[i] / songSpeed;
                  // Play tone if currentNote is not 0 frequency, otherwise pause (noTone)
                  if (currentNote != 0)
                  {
          // light sensor	/* the light value is being printed. Now you can know how much light there has to be, before you can push the button (or throw the knife). You have to enter the number twice after "if (analogvalue > " (now it's 400). The first time is 6 rows down below. The second time is a bit later */
                                        analogValue = analogRead(lightSensorPin);
                                        Serial.println(analogValue);
          // servo + push button (+ light)
                                                if(digitalRead(pushButtonPin) == LOW){
                                                  if (analogValue > 400)	//FIRST TIME CHANGING THE AMOUNT OF LIGHT
                                                  buttonPushed = 1;
                                                }
                                                 if( buttonPushed ){
                                                // change the angle for next time through the loop:
                                                angle = angle + angleStep;
                                             	// reverse the direction of the moving at the ends of the angle:
                                                  if (angle >= maxAngle) {
                                                    angleStep = -angleStep;
                                                      if(type ==1)
                                                      {
                                                          buttonPushed =0;                   
                                                      }
                                                  }
                                                  
                                                  if (angle <= minAngle) {
                                                    angleStep = -angleStep;
                                                     if(type ==2)
                                                      {
                                                          buttonPushed =0;       
                                                      }
                                                  }
                                                  
                                                  myservo.write(angle); // move the servo to desired angle
                                                    Serial.print("Moved to: ");
                                                    Serial.print(angle);   // print the angle
                                                    Serial.println(" degree");    
                                                delay(200); // waits for the servo to get there SPEED
                                                 }

                                        
                    tone(buzzer, notes[i], wait); // tone(pin, frequency, duration)

          // LEDs dance to the music
		/* Here you can add more leds just as you like, you can also create more scenarios*/
                                        int rand_num = random(5);	// Now there are 5 scenarios (0, 1, 2, 3 and 4). A scenario gets randomly picked every time a note is being played.


                                        if (rand_num==0){			// scenario 1
                                        digitalWrite(led_1, HIGH);
                                        digitalWrite(led_2, LOW);
                                        digitalWrite(led_3, LOW);
                                        digitalWrite(led_4, LOW);
                                        digitalWrite(led_5, LOW);
                                        }
                                         if (rand_num==1){			// scenario 2
                                        digitalWrite(led_1, LOW);
                                        digitalWrite(led_2, HIGH);
                                        digitalWrite(led_3, LOW);
                                        digitalWrite(led_4, LOW);
                                        digitalWrite(led_5, LOW);
                                        }
                                         if (rand_num==2){
                                        digitalWrite(led_1, LOW);
                                        digitalWrite(led_2, LOW);
                                        digitalWrite(led_3, HIGH);
                                        digitalWrite(led_4, LOW);
                                        digitalWrite(led_5, LOW);
                                        }
                                         if (rand_num==3){
                                        digitalWrite(led_1, LOW);
                                        digitalWrite(led_2, LOW);
                                        digitalWrite(led_3, LOW);
                                        digitalWrite(led_4, HIGH);
                                        digitalWrite(led_5, LOW);
                                        }
                                         if (rand_num==4){
                                        digitalWrite(led_1, LOW);
                                        digitalWrite(led_2, LOW);
                                        digitalWrite(led_3, LOW);
                                        digitalWrite(led_4, LOW);
                                        digitalWrite(led_5, HIGH);
                                        }
                      }
                      else
                      {
                        noTone(buzzer);
             // light sensor
                                        analogValue = analogRead(lightSensorPin);
                                        Serial.println(analogValue);
            // servo + push button (+ light)
                                                  if(digitalRead(pushButtonPin) == LOW){
                                                    if (analogValue > 400)	//SECOND TIME CHANGING THE AMOUNT OF LIGHT									
                                                    buttonPushed = 1;
                                                  }
                                                   if( buttonPushed ){
                                                  // change the angle for next time through the loop:
                                                  angle = angle + angleStep;
                                                
                                                    /* reverse the direction of the moving at the ends of the angle:*/
                                                    if (angle >= maxAngle) {
                                                      angleStep = -angleStep;
                                                        if(type ==1)
                                                        {
                                                            buttonPushed =0;                   
                                                        }
                                                    }
                                                    
                                                    if (angle <= minAngle) {
                                                      angleStep = -angleStep;
                                                       if(type ==2)
                                                        {
                                                            buttonPushed =0;       
                                                        }
                                                    }
                                                    
                                                  myservo.write(angle); // move the servo to desired angle
                                                      Serial.print("Moved to: ");
                                                      Serial.print(angle);   // print the angle
                                                      Serial.println(" degree");    
                                                  delay(200); // waits for the servo to get there SPEED
                                                   }

                      }
                      // delay is used to wait for tone to finish playing before moving to next loop
                      delay(wait);
                    }



}

Step 3: Build Your Own Person Who Throws Something at a Rotating Disk

The pushbutton and speaker stay on the breadboard.

The servo motor is attached the arm. (He hrows a knife.)

I put the DC motor into a piece of cardboard that doesn't move/rotate.
In that same piece, I put the LEDs around the edge.
Idem for the light sensor, BUT here you'll have to be precise.
You have to put it at the right place according to your rotating disks.

You can make different kind of disks. These can be different leves.
(The more cutouts you make, the harder the level.)

Step 4: Add Something More

When you can throw, if you push the button, there's no feedback yet.
Maybe that's someting you can add...

E.g. you throw the knife and then you hear the sound of a knife hitting wood.