Arduino Nerf Target Practice




About: Science museum exhibit design and fabrication manager, stagehand, ballet shoe maker, theatre production manager, project manager and art director of the Beijing Aquarium rainforest exhibit, film extra, archi...
Arduino + 2 servos + laser

Switch it on and the servos move to a random position and turn on the laser target. You have 2 seconds to hit it before it switches off and moves to a new random position. Servo positions are limited to 0 to 180 degrees on the x-axis and 90 to 180 degrees on the y-axis so that as long as you stand behind it targets will all appear in front of you and there's no danger of getting zapped by a laser in your eye!

Step 1: Build It

1: Servos

I've used a pan-tilt mechanism but it will work just as well by sticking one servo to the rotor arm of the other. Attach the x-axis servo control wire to Digital 8 pin and the y-axis servo to digital 9. For both servos the positive wire goes to 5v pin and ground to GND, both viaa breadboard.

2: Laser

Positive wire goes to digital 4 pin and ground to GND via the breadboard. I added a target shaped lens to the laser which came with a cheap laser pointer.

3: Power

Add a 9v battery. Ground wire goes to GND via the breadboard and positive goes to VIN pin via any kind of on/off switch.

4: Packageing

Put it all in a plastic food storage box or similar, cutting holes for the switch, servo and wires.

Step 2: Code

// Nerf Target Practice
  // J Robson

  #include <Servo.h>

  Servo myservo1;      // x- axis servo
  Servo myservo2;      // y- axis servo

  int pos = 0;                   // variable to store the servo position

  long randNumber;    // Initialise a variable for a random servo position

  void setup()
  myservo1.attach(8);   // attaches the x axis servo on digital pin 8
  myservo2.attach(9);   // attaches the y axis servo on digital pin 9
  pinMode(4, OUTPUT);   // attaches the laser to digital pin 4

  void loop()
  myservo1.write(randNumber = random(0, 180));  // servo to random position on the x axis between 0 and 180 degrees

  delay(500);                             // waits half a second for the servo to reach the position
  myservo2.write(randNumber = random(90, 180));  // servo to random position on the y axis between 90 and 180 degrees

  delay(500);                             // waits half a second for the servo to reach the position

  digitalWrite(4, HIGH);                 // turn on the target laser
  delay(2000);                          // target laser stays on for 2 seconds
  digitalWrite(4, LOW);                // turn off the target laser

Step 3: Shoot!

Load up a Nerf gun, stand BEHIND the device with the laser pointing AWAY from you and switch it on. It'll keep on giving you targets to shoot at until you switch it off or the battery runs out.



    • Warm and Fuzzy Contest

      Warm and Fuzzy Contest
    • Remix Contest

      Remix Contest
    • Paper Contest

      Paper Contest

    3 Discussions


    The parts, and what to do with them, are listed in step1. There is even an annotated diagram of them all.