Motion Decting Nerf Gun

Introduction: Motion Decting Nerf Gun

About: I love Raspberry pi, Nerf, Minecraft, 3D printing, and raspberry pie😁.

Hi! I'm Cameron. For this Instructable I show you how to make a motion activated Nerf gun. It is somewhat hard, but 100% AWESOME!!!

Supplies:

1. electric Nerf gun

2. Raspberry Pi (b+ and newer)

3. Battery Bank (2 amp and above)

4. PIR module (5 volts)

5. relay (I used a Songle SRD-05VDC-SL-C)

6. bits and pieces (breadboard, jumper wires, micro sd card, etc)

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: Unscrew the Gun

This step is probably the simplest thing in this instructable. Just unscrew all the screws (outside only!).

Step 2: Remove the Battery Pack

This step was annoyingly hard on my Nerf gun. Remove all the screws and or glue.

Step 3: Attach the Battery Pack From the Nerf Gun

Simple! Hook up the negative side of the battery pack to the negative wire on the Nerf gun, then the positive to the center of your relay (it's the center on mine, but you will want to double check to make sure).

Step 4: Attach the MOTORS!!

Attach the positive wire(s) of the Nerf gun to the NO (Normally Open) part of the relay (mine was the right side).

Step 5: Attach the Relay

Hook up the data pin of the relay to GPIO 21 (bottom right) on the Raspberry Pi, GND up to Ground, and 5V to 5V.

Step 6: Hook Up the PIR

Hook up the data pin on the PIR to GPIO pin 4, GND to Ground, and finally 5V to 5V.

Step 7: Code It With Python

############################Here's the code!#################################

print ("Welcome!)

print ("Importing modules...")

from gpiozero import MotionSensor

import RPi.GPIO as GPIO

from time import sleep

sleep(0.2)

print ("Complete!)

print ("Setting up GPIO...")

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM
GPIO.setup(21, GPIO.OUT)
sleep(0.3)
print ("Complete!!")
sleep(0.1)


print ("Please wait for PIR to settle...")
pir.wait_for_no_motion
sleep(1)
print ("settled!")
while True:
	print ("Ready to fire...")
	pir.wait_for_motion()
	print ("Motion detected!!!")
	print ("FIRE!!!")
	GPIO.output(21, True)
	sleep(1)print ("Powering off")
	GPIO.output(21, False)

Step 8: Turn It On!

Steps:

1. tie the trigger with rope so it's is stuck to the on position

2. run the Python code

3. sprint away... OR GET SHOT!!!

I hope you enjoyed this Instructable, bye!

-Cameron

Reuse Contest

Participated in the
Reuse Contest

1 Person Made This Project!

Recommendations

  • Magnets Challenge

    Magnets Challenge
  • Raspberry Pi Contest 2020

    Raspberry Pi Contest 2020
  • Wearables Contest

    Wearables Contest

Discussions

0
Computer Kid
Computer Kid

Tip 6 weeks ago

Put the PIR inside a paper towel role and point it at the area you want to detect motion in (-: