Introduction: Interactive Shooting Gallery

About: I like to dream big, do a lot of planning, start projects, and for some reason abandon projects once I realize that everything I want to do in that project is completely possible, not complicated, and I could …

For my first ever submission to Instructables I will be building an interactive shooting gallery. I will be using an Arduino, An IR sensor harvested from a broken DVD player, a 555 timer monostable circuit, and a servo for the basis of the project. I am just in the breadboard stage so I thought it would be a good time to start an instructable. The image came from tripadvisor website.

********

Update. I realize others have done similar actually bigger and better projects than this. However a lot of them are advanced beyond my experience level, and sometimes include things I don't already have at home. I am using the most basic of Arduino principles, and basic common circuits. I feel like I have something the "average Joe" could do with little knowledge.

Step 1: Planning the Layout

This step is sort of self explanatory, however it determines a few things about how you proceed. There are several ways you can plan your layout. The main thing is deciding how many targets you want, and what the targets will do. Possible target actions to consider could be move a servo, light up, activate a relay, etc. So get detailed and use Google Sketchup, or have a few drinks and draw on a cocktail napkin. It's up to you. I decided to start with a Sketchup rendering. First I modeled the area that I will be using. Then I added red cubes to visualize target placement. 

Step 2: Build the Target Part 1

The target includes a couple of circuits. There may be a simpler way to do this, but do to either my lack of knowledge, or the limitations of Arduino I can't get multiple targets to work without the 555 timer circuit. I am using the very basics of the Arduino sketch and using a delay to keep a target in a changed state temporarily makes everything else stop working. So I am using a 555 timer monostable circuit as a hardware solution.

I start by building the 555 timer monostable circuit as depicted in the graphic. You can decide on your own how long you want your target to remain in a changed state. This will determine the value of the resistor, and the capacitor that are in line ( I have a 100k and a 47uF). To learn everything about the 555 timer and find a calculator for resistor/ capacitor values go to this website  http://www.555-timer-circuits.com/which is where the schematic came from.

*******
Update. I guess a little explanation of what takes place here wouldn't hurt. The 555 circuit timer monostable circuit when triggered will take the output pin ( pin 3 ) high for a duration determined by your resistor/ capacitor combination. The circuit is triggered by a low signal on pin 2 which comes from the IR sensor.

Step 3: Build the Target Part 2

Now that you have your 555 monostable built you will need a way to trigger it. There are many possibilities for this. For my experimental stage I am using an IR sensor and a common T.V. remote controller. This will not be my final solution because the main drawback is that the IR scatter allows you to "hit" the IR sensor pointing anywhere in the room. Some possibilities I am considering are an IR sensor with a device that has a narrow beam, A laser pointer with a sensor (somewhat dangerous), or maybe a physical target that you can hit with a Nerf dart gun. Now on to the example. I am using an IR sensor I harvested from a broken DVD player. Connection is simple.

*******

Update. Adding a little explanation. When wired as shown the output pin will remain maintain a high signal until it senses input from an IR source. When the IR source is detected the output signal is low.

Step 4: Build the Trigger Part 2 Alternative

If you are looking at the possibility of a physical target for a Nerf dart gun, air soft gun, etc. this site will tell give you a technique that can be adapted to this project. It uses a piezo and a metal plate. check it out http://www.electronicdrums.com/pads/pads2.htm Steps 3 and 7 are a bare bones example for possible adaptation to this project. I plan to try it out and provide pics/ diagrams later.

I have also built my own version of a physical target using an old DVD-r, some foam board, a push button, and some hot glue. I may also post pictures/ descriptions of that.
Something new I learned with this was how to trigger the 555 monostable circuit using a SPST push button. In a sense using a high signal to trigger the 555 timer

*******

Update. I built this piezo target today. The particular piezo I used takes the signal low when hit from the target side. So the resistor is not needed. The piezo wires would go between the voltage supply rail, and the input pin2.

Step 5: Build the Target Part 3

This will be the part of the target that performs an action. In my case a servo moves from 0 to 90 degrees and back. The servo connection is simple, however wire color can vary by manufacturer. In most cases it is red, black (sometimes brown), and a third color which on the servos I have is yellow or orange.

*******

Update. Again to add a little explanation. Servo voltage/ current requirements vary by servo size and type. My servo is very small and will run on 5 volts @ about 200 mA. The servo requires two things power, and a signal. I don't exactly remember how the signal works I do know that certain pulse widths equal different actions. The signal comes in on the yellow wire ( color may vary ) from the Arduino which generates the proper pwm.

Step 6: Build the Target Part 4

Next step is to combine the circuits with an Arduino to test everything out. For some reason that I can only explain as magic, this only works for me if the Arduino, The servo, and the IR sensor/555 timer have separate power. I plan to investigate this as I go into final production. My theory Is that my power supply (cell phone wall wart) lacks the current capacity to run all of this together. The arduino currently is powered through the USB attached to my computer. The servo is powered by a 5v cell phone charger, and the IR sensor and the 555 timer are powered together by a 5v cell phone charger. After you hook it all up upload this sketch to arduino, get an IR device such as a T.V. remote control, and try it out

***********************************************

Update. I am adding an explanation of what is going on in each step. In this step we start with the IR sensor. The sensor is allowing 5v to pass through sending a high signal to the 555 timer circuit. When the IR sensor receives an IR input it switches, sending the signal to the 555 timer low. That is where the IR sensors' job ends.

The 555 timer takes over here. The 555 timer circuit puts out a low signal through the output pin until it receives a low signal through the input pin from the IR sensor. A low on the input pin triggers the circuit to send the output pin high for an amount of time determined by the value of the resistor and capacitor, after which time the signal to the output pin is taken low again.

This is where the Ardiuno comes in. The Main purpose of the Arduino is to supply a pwm signal to drive the servo. The Arduino sends a signal telling the servo to move to zero and repeats the loop in this state until it receives a high signal from the 555 timer on the designated input pin (A0 in this case). When A0 receives a high signal the Arduino generates a pwm signal telling the servo to move to 90 degrees then the sketch loops back to the beginning and continues to repeat the loop in the 90 degree state until A0 receives a low again from the 555 timer and returns to zero. Remember the 555 circuit stays high for a given amount of time allowing us to keep the signal high and the servo at 90 degrees for a few seconds without putting a delay in the sketch.

There may be a way to eliminate the 555 timer by adapting something like the blink without delay sketch to hold the servo at 90 degrees for a few seconds. I have tried on my own to adapt the blink without delay code however probably due to my lack of understanding I haven't been successful at it. So for now I will stick with my hardware solution.

There is a benefit to using the 555 timer circuit. The output from the 555 circuit can be used for less complex tasks for example, trigger a relay, light up some LEDs, anything that can be done with simple high and low signals can be controlled by the timer. This leaves the Arduino free to do more complex tasks. Also it expands the number of possible targets. An Arduino Nano has 8 analog pins. Due to my limited knowledge of programming that only gives me 8 inputs for targets, which in turn I only use 8 digital pins to output to targets. So my Arduino is limited to 8 targets. If I were to use a 555 timer to control relays, lights, etc. the number of possible targets is unlimited.

This is a short sketch to control one servo on digital pin 6 using input on analog pin A0

#include <Servo.h>
int sensorpin0 = A0;                 // analog pin used to connect the sharp sensor

int val0 = 0;                 // variable to store the values from sensor(initially zero)


Servo myservo0;  //create servo object to control a servo


int pos = 0;


void setup()
{
  Serial.begin(9600);               // starts the serial monitor
  myservo0.attach(6);  //attaches the servo on pin 7 to the servo object

}

void loop()
{
  val0 = analogRead(sensorpin0);       // reads the value of the sharp sensor
  if (val0 > 10) {
     myservo0.write(90);           //change the servo position to 90
   }

   else{
     myservo0.write (0);}

}

Step 7: Finish the Target

After watching a servo cycle 0 to 90 degrees and back about a thousand times I decided to add some character.

Step 1) Tape a stick to the servo horn

Step 2) Tape a can to the stick

Step 3) Watch the can fall over and set back up.
Video of the target in action http://youtu.be/WHiHoZ8MJ2w

Step 8: Build It All

For me this step is not complete. It includes building, wiring and placing all of the targets, and building your trigger device if necessary. As I complete my project I will add more details.

Here is my full 8 target 8 servo sketch

*******

Update I discovered that if you attempt to use this full code with only one sensor/ servo, you have to connect all of the unused analog pins to ground. Also the graphic shows my current breadboard setup with an Arduino Nano. It demonstrates having only one IR sensor and one servo.

#include <Servo.h>
int sensorpin0 = A0;                 // analog pin used to connect the sharp sensor
int sensorpin1 = A1;                 // analog pin used to connect the sharp sensor
int sensorpin2 = A2;                 // analog pin used to connect the sharp sensor
int sensorpin3 = A3;                 // analog pin used to connect the sharp sensor
int sensorpin4 = A4;                 // analog pin used to connect the sharp sensor
int sensorpin5 = A5;                 // analog pin used to connect the sharp sensor
int sensorpin6 = A6;                 // analog pin used to connect the sharp sensor
int sensorpin7 = A7;                 // analog pin used to connect the sharp sensor


int val0 = 0;                 // variable to store the values from sensor(initially zero)
int val1 = 0;                 // variable to store the values from sensor(initially zero)
int val2 = 0;                 // variable to store the values from sensor(initially zero)
int val3 = 0;                 // variable to store the values from sensor(initially zero)
int val4 = 0;                 // variable to store the values from sensor(initially zero)
int val5 = 0;                 // variable to store the values from sensor(initially zero)
int val6 = 0;                 // variable to store the values from sensor(initially zero)
int val7 = 0;                 // variable to store the values from sensor(initially zero)


Servo myservo0;  //create servo object to control a servo
Servo myservo1;  //create servo object to control a servo
Servo myservo2;  //create servo object to control a servo
Servo myservo3;  //create servo object to control a servo
Servo myservo4;  //create servo object to control a servo
Servo myservo5;  //create servo object to control a servo
Servo myservo6;  //create servo object to control a servo
Servo myservo7;  //create servo object to control a servo


int pos = 0;


void setup()
{
  Serial.begin(9600);               // starts the serial monitor
  myservo0.attach(6);  //attaches the servo on pin 7 to the servo object
  myservo1.attach(7);  //attaches the servo on pin 7 to the servo object
  myservo2.attach(8);  //attaches the servo on pin 7 to the servo object 
  myservo3.attach(9);  //attaches the servo on pin 7 to the servo object
  myservo4.attach(10);  //attaches the servo on pin 7 to the servo object 
  myservo5.attach(11);  //attaches the servo on pin 7 to the servo object 
  myservo6.attach(12);  //attaches the servo on pin 7 to the servo object 
  myservo7.attach(5);  //attaches the servo on pin 7 to the servo object 

}

void loop()
{
  val0 = analogRead(sensorpin0);       // reads the value of the sharp sensor
  val1 = analogRead(sensorpin0);       // reads the value of the sharp sensor
  val2 = analogRead(sensorpin0);       // reads the value of the sharp sensor
  val3 = analogRead(sensorpin0);       // reads the value of the sharp sensor
  val4 = analogRead(sensorpin0);       // reads the value of the sharp sensor
  val5 = analogRead(sensorpin0);       // reads the value of the sharp sensor
  val6 = analogRead(sensorpin0);       // reads the value of the sharp sensor
  val7 = analogRead(sensorpin0);       // reads the value of the sharp sensor


  if (val0 > 10) {
     myservo0.write(90);           //change the servo position to 90
   }
  else if (val1 > 10) {
     myservo1.write(90);           //change the servo position to 90
   } 
  else if (val2 > 10) {
     myservo2.write(90);           //change the servo position to 90
   }    
    else if (val3 > 10) {
     myservo3.write(90);           //change the servo position to 90
   }  
   else if (val4 > 10) {
     myservo4.write(90);           //change the servo position to 90
   }   
   else if (val5 > 10) {
     myservo5.write(90);           //change the servo position to 90
   }
   else if (val6 > 10) {
     myservo6.write(90);           //change the servo position to 90
   }
   else if (val7 > 10) {
     myservo7.write(90);           //change the servo position to 90
   }

   else{
     myservo0.write (0);
     myservo1.write (0);
     myservo2.write (0);
     myservo3.write (0);
     myservo4.write (0);
     myservo5.write (0);
     myservo6.write (0);
     myservo7.write (0);}

}

Step 9: Improve on This

This is just the start. Feel free to help me improve this. Some improvements I would like to make.

A two player version that keeps score. I imagine using two IR based "guns" that output different pulses. The Arduino could then possibly determine which player hit the target and adjust the score accordingly. The score could be shown on 7 segment displays. I have a lot to learn before I could attempt this.

Another would be to add a start button and have the targets active for a timed limit after the start button is pressed. I could probably do this right now with a relay, and a 555 timer or something. Or maybe an addition to the code.

Remote Control Contest

Participated in the
Remote Control Contest

Toy Contest

Participated in the
Toy Contest

Arduino Contest

Participated in the
Arduino Contest