Arduino Nerf Target Practice




Introduction: Arduino Nerf Target Practice

Science museum exhibit design and fabrication manager, stagehand, ballet shoe maker, theatre prod...
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!

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

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.

Toy Contest

Participated in the
Toy Contest

Be the First to Share


    • Trash to Treasure Contest

      Trash to Treasure Contest
    • Rope & String Speed Challenge

      Rope & String Speed Challenge
    • Fix It Contest

      Fix It Contest

    3 Discussions

    Jacky P
    Jacky P

    6 years ago

    What are all the parts?

    Jonathan Robson
    Jonathan Robson

    Reply 6 years ago on Introduction

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