loading
Tools:
Hot Glue Gun
Laptop with Arduino software
22 awg hookup wire (black, red, yellow)
wire strippers
usb cable
drill
1/16th drillbit
exacto knife

Parts:
2 tongue depressors
1 clothespin
1 rubber-band
1 dart
1 cup (paper or plastic)
1 arduino
1 breadboard
1 led
1 momentary button switch
1 22k ohm resister
1 0.1uf capacitor
1 10k ohm resister
1 infra red sensor 

Step 1: Assemble the Crossbow

1) hot glue the two tongue depressors together in a T shape.
2) notch the top piece in two places near each edge
3) break a rubberband and tie it in two knots at each of the notches
4) hotglue a clothespin to the back of the T
5) test your crossbow

Step 2: Prepare Crossbow for Digital Control

1) drill a small hole through the back of the clothespin
2) strip a 2 inch piece of hookup wire
3) attach the wire to the clothespin
4) rubberband or hotglue a servo to the bottom of the clothespin
5) attach the wire from the clothespin to the arm of a servo
6) hookup the servo to the breadboard (redwire to power, blackwire to ground)
7) hookup the servo to the arduino (yellow wire to pin 10)
8) power the breadboard from the arduino (5v and ground)
9) hookup a monentary switch from ground on the breadboard to pin 2 on the arduino
10) program the aruduino with the following code  
      --- for more on how to program arduinos; check out this video series  http://www.youtube.com/watch?v=fCxzA9_kg6s
11) test the digital dart gun, by pressing the button
/////////////////////////////////////////////////////////////////////////////
//TRIGGER TEST by mdwilson 5/1/2013
#include <Servo.h>


Servo trigger;  // create servo object to control a servo
const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin
int buttonState = 0;         // variable for reading the pushbutton status

void setup()
{

 
  pinMode(ledPin, OUTPUT);   // initialize the LED pin as an output:  
  pinMode(buttonPin, INPUT);    // initialize the pushbutton pin as an input: 
  digitalWrite(buttonPin,HIGH);
  trigger.attach(10);  // attaches the servo on pin 9 to the servo object
  trigger.write(0);// set up initial trigger position
}

  
void loop()
{
   // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);
  // if the button is pressed than shoot
  if (buttonState == LOW) {    
   trigger.write(45);//send the trigger servo to 45 degrees
   digitalWrite(ledPin, HIGH);// turn on the led
   delay(1000); //wait 1 second
   trigger.write(0); //send the trigger servo back to 0
   digitalWrite(ledPin, LOW); //turn off the led
  }
}

Step 3: Electronics

1) attach another servo (sentry)  to bottom of crossbow
2) attach servo (sentry) to breadboard and pin 9 of the arduino
3) attach IR sensor to front of the crossbow
4) attach IR sensor to breadboard (power and ground) and arduino (pin A0)
5) add low pass filter to breadboard using a 0.1 uf capacitor and 22k ohm resistor to clean up the IR signal (if needed).

see attached schematic
if you wanted to use a photoresister instead of an IR sensor, check out this instructable:
https://www.instructables.com/id/Control-Servo-with-Light/

Step 4: Program



program the arduino with the following code
///////////////////////////////////////////////////////////////////
//SENTRY by mdwilson 5/1/2013
#include <Servo.h>

Servo sentry;  // create servo object to control a servo
Servo trigger;  // create servo object to control a servo
const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin
int buttonState = 0;         // variable for reading the pushbutton status
int tooClose=350; //how close is too close for the ir sensor?
int servoSpeed=100;  // how slow do you want the turent to move?          
int pos = 0;    // variable to store the servo position
boolean intruder =false; // is there is or is there aint an intruder?
void setup()
{
 
  pinMode(ledPin, OUTPUT);   // initialize the LED pin as an output:  
  pinMode(buttonPin, INPUT);    // initialize the pushbutton pin as an input: 
   digitalWrite(buttonPin,HIGH);
  Serial.begin(9600);  // make serial communication possible
  sentry.attach(9);  // attaches the servo on pin 9 to the servo object
  trigger.attach(10);  // attaches the servo on pin 9 to the servo object
  trigger.write(0);// set up initial trigger position


}

  
void loop()
{
   // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  if (buttonState == LOW) {    
    intruder=false;
    Serial.println("reset");
  }
  //Serial.println("in= "+intruder);
  //as long as there is no intruder, continue to search
if(!intruder){
  for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees
  {
if (intruder){
break;
}
// in steps of 1 degree
    sentry.write(pos);              // tell servo to go to position in variable 'pos'
    delay(servoSpeed);                       // waits  for the servo to reach the position
    intruderCheck(); 
}

  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees
  { 
if (intruder){
break;
}   
    sentry.write(pos);              // tell servo to go to position in variable 'pos'
    delay(servoSpeed);                       // waits for the servo to reach the position
    intruderCheck();
  }
}else{
   //set off the alarm
   alarm();
}
}
//make the alam led blink
void alarm(){
  digitalWrite(ledPin, HIGH);
  delay(200);
  digitalWrite(ledPin, LOW);
  delay(200);
}

//check to see if the ir sensor sees an object
void intruderCheck()
{
    int sensorValue = analogRead(A0);
    // print out the value you read:
    Serial.println(sensorValue);
  if (sensorValue>tooClose && !intruder)
  {
   
    delay(100);
    shoot();
   intruder=true;
 
  }
}
void shoot()
{
  Serial.println("triggered!");
  Serial.println(" intruder= "+ intruder);
  trigger.write(45);
  delay(1000);
  trigger.write(0);
}

Step 5: Make It Work

You now have all the knowhow to build a weaponized robotic sentry.
For more strange fun with servos and arduinos, check out this instructable for an animatronic doll:
https://www.instructables.com/id/Simple-Animatronics-with-Servos/


<p>this is so cool! Thanks but do you know if you can make it wireless? But thanks a ton!!!</p>
<p>Love it!!!</p>

About This Instructable

8,767views

42favorites

License:

More by mdwilson42:How to make a robotic dart shooting sentry 
Add instructable to: