Introduction: WiFi / Internet / Android Controlled Nerf Vulcan Sentry Gun
Using a WiFi shield to connect to a router, control a sentry gun using a terminal emulator installed on your laptop, or with an app installed on your Android device.
If your router is connected to the internet, this sentry gun could theoretically be controlled from anywhere in the world as long as you can access that IP address. With a separate WiFi Webcam installed, you also have to ability to remotely view what the sentry gun is seeing.
Well documented code is provided to enable you to perform further experimentation with the platform.
Step 1: Essentials
You will require the following items, or equivalent.
1) Nerf N-Strike Vulcan EBF-25 Blaster with Ammo Box & Ammo Belt.
2) Lynxmotion BotBoarduino.
3) Arduino WiFi Shield.
4) 2 x HS-805BB Giant Scale Servo Motors.
5) WiFi Router ( any ).
6) PuTTY Terminal Emulator. Download here... http://www.putty.org
7) Android device ( optional ) ... phone or tablet.
8) Webcam ( optional ).
9) Power ( see explanation in later step ).
Step 2: Build Your Sentry Gun
Visit this previously published Instructable for a detailed explanation on that.
You will require basic woodworking and general "maker" skills, but that's half the fun of most of these types of projects. Don't be afraid of this aspect of larger Arduino projects... put down your smartphone and try playing with a powertool for awhile!
When you're done building something, the rest of this Instructable will step you through controlling it...
Step 3: BotBoarduino Explained
The shield compatible Lynxmotion BotBoarduino is perfect for controlling any Arduino (Duemilanove) based project, but especially those requiring servos.
It has an onboard speaker (hardwired to pin 5), three onboard pushbuttons with corresponding LED's, a reset button, separate logic and servo power inputs, an I/O bus with 20 pins and power and ground, and a 5vdc 1.5amp regulator.
Up to 18 servos can be plugged in directly, and powered separate from the logic circuit of the board in this manner (refer to image above)...
(15) VS is the power input for the servos. Whatever power you run into here will be directly used by the servos.
(16) VL is the power input for the logic circuit... ie... to run the board itself.
(13) is a jumper you remove to separate the VS and VL power circuits.
The digital pins 2 through 13 are arranged in banks of 4 ( 2-5, 6-9, 10-13). Each bank has a jumper next to it where you can select the power source for that bank. For example, you could set the jumper for bank 10-13 to VS to power servos, and set the jumper for bank 6-9 to 5V to power sensors.
As spectacular as this sentry gun is, at its heart it is a simple two servo control project. Configure your BotBoarduino to have separate VS/VL power sources, jumper a digital pin bank for VS, and plug your two servos, plus the control lines for the trigger motor on the gun, into that bank. See provided code for actual pinouts, and match or change as per your requirements.
If you're not using a BotBoarduino, you'll just configure your servos for your situation. HOWEVER, if you don't already know this, you can't run your servos directly from a standard Arduino because the power draw is too high. If need be, see other Instructables for Arduino / Servo information.
Step 4: WiFi Shield Explained
The Arduino WiFi Shield connects your Arduino to the router ( and the internet ) wirelessly. This is the necessary hardware component, the actual connectivity is embedded in the code installed on the Arduino.
These shields come in many different versions, so this Instructable does not require a specific one. The provided code should be the same for all. See there for specifics.
Depending on your Arduino / WiFi shield combination, you might have to perform a small hardware hack. My shield would initially not work because there was no IOREF pin on the BotBoarduino. Patching 5V to IOREF on the WiFi shield fixed the problem because that's what IOREF required. "Hacking" code and hardware is part of the Arduino experience!
Step 5: Power Your Project
There are lots of ways to power the sentry gun. The simplest would be a couple of 6v AC/DC power adapters, one for the servos, one for the board. The universal power adapters are a great choice for gadgeteers, so if you need to buy adapters, go with them.
If you want standalone capabilities so you can place this anywhere (ie outside) , you would then go with battery power.
The first version of this project used simple packs of AA batteries which was good enough for "proof of concept", but not suitable for extended use. Be prepared to buy crates of disposable AA batteries, or be forever refreshing your rechargables.
If you want to go the battery route, go with higher strength rechargeable packs. There are lots of options there... pictured are a few I've used successfully in many projects.
If you're unsure of all of this, just start as simple as possible, and change your power sources as you better understand your needs. It is assumed a project such as this is not your first build, so you probably have a rudimentary knowledge of power.
Step 6: The Algorithm
To control the sentry gun remotely, we wanted a simple algorithm that was easy for beginners to understand, correct enough to control the gun in the manner we wanted, and robust enough to be easily modified and added to.
Since the simplest thing to send between two devices is a single character, we quickly established the algorithm should be based on this... a single character would tell the gun a specific action to perform.
So, as an example, let's look at controlling the gun pan (going back and forth)...
For various reasons unimportant to you at this point, we determined our desired pan range to be from 52 degrees (right) to 152 degrees (left). Your desired pan range could be different, it's an easy mod to the program.
We decided to use the letters A through Z to move the pan servo through this range of angles. With that decided, the next step was simply to "map" the letters A though Z to the angles 52 through 152. Simple math will tell you with this scheme each letter will represent approx 4 degrees of servo movement.
So, A would be 52 degrees, B would be 56 degrees, C would be 60 degrees, etc etc, all the way to Z which would be 152 degrees.
A simple scheme that is easy to understand, change, and add to.
Below are the choices we made for my program. When you look at the source code you'll see how easy it is to mod all of this to your desired actions, or go with it as is.
( a - z ) Controls tilt between 65 and 115 degrees, in 2 degree steps
( A - Z ) Controls pan between 52 and 152 degrees, in 4 degree steps
( 0 ) Fires a single round
( 9 ) Fires three round burst
( + ) Starts automatic panning
( - ) Stops automatic panning
Step 7: Install Code
I've provided an extensively documented Arduino sketch that provides the functionality as described in the previous steps..
If you've configured your components correctly, it should work as is. Some fine tuning will probably be required. Or, you could hack the code to suit your needs.
We had problems getting the WiFi board functional when compiling our sketch with newer versions of the Arduino IDE. That must have to do with changes in the library code. Rather than bore you with all the details, I've just included a zip of the IDE that works with our board. You may want to try it if your board is not responding to connection or command attempts.
Step 8: PuTTY Explained
PuTTY is a free and open-source terminal emulator that enables you to simply connect to a remote platform. Most experienced programmers are familiar with it for one reason or another. The good news is that you don't need to be an experienced programmer to use it.
You can read more about it ( optional ) and download it at putty.org .
PuTTY will enable you to connect to your sentry gun and send simple characters to control it as was explained earlier.
It is assumed you have a rudimentary knowledge of networking, so all you need to do here is determine the IP address of your gun, set up an entry in PuTTY, and connect.
Once connected, send the character corresponding to the action you desire, and the gun should respond. See the program code to determine character/action mappings.
This step was always intended as a simple "proof of concept", and should serve the same for you. Once you have everything fully operational, you'll no doubt be better served by the provided Android app...
Step 9: Android App
At this point, you should understand that the sentry gun reacts to characters it receives from another device.
PuTTY gives you a simple capability to send characters, but you would be better served with a more elaborate control interface.
Since this project is designed to work over the internet, why not use the most popular device available today as your interface... your smartphone?
This simple Android app gives you a Graphical User Interface (GUI) to control your gun with. As fancy as it looks, all it does is turn touch commands into the characters discussed earlier in the algorithm.
If you mounted a camera on your gun (see next step), it also receives the video stream and displays it.
Step 10: Remote Viewing
A remote sentry is blind without some sort of video tech mounted on it! Remote viewing can be accomplished three (or more) different ways...
1) (Easy but $$$) Mount a standalone wireless IP camera. There's lots of these available.
1) (Difficult for beginners but $$ ) Use a stand alone Raspberry Pi with Camera Module. If you were looking for an excuse to play with Raspberry Pi, here it is. That's what we used. More info here.
2) (Easy and free) Repurpose an old smartphone... you or your friends probably have a drawer full of these by now. The nice thing about this option is the smartphone has its own battery, so it's just a matter of mounting it to your platform and configuring. There are lots of online resources to show you how to do this. Perhaps you would like to start with this Instructable "Make A Wi-fi Webcam From An Old Android Phone" .
Step 11: Other Projects
Once you have your gun fully operational, here are some ideas for other capabilities...
1) Mount a Red Dot Laser Module onto the gun so you can see what you are targeting, just like you see on every action movie these days. For more info on that, see "Optional Weaponry" on my "Autonomous Sentinel Arduino Vehicle".
2) Incorporate sensors to add autonomous "seek and destroy" functionality, easily done using concepts from my "Autonomous Sentinel Arduino Vehicle" . Your sentry gun could remain stationary, or if you have serious budget and skills (ie perhaps you're looking for a large college/university project), you could mount it on a platform such as a repurposed Jazzy. The concepts should be the same as my Sentinel Vehicle, just amped up with "heavy metal".
3) Add a CMUcam5 Pixy to autonomously track colors / patterns such as seen later in this YouTube video .
4) Perhaps you'd rather ditch the WiFi concept in favor of local 1Sheeld control. As a 2 servo project, it would just be a downscaled version of the program found in my Instructable 1Sheeld Controlled Robotic Arm .
5) Heads Up Display (HUD) control using SNOW2 HUD & UVEX G.GL 9 goggles. The gun moves in response to your head movements ("shoot where you look"), like a helicopter gunship, and you can view target info on the onboard display screen. For more information, visit my Instructable Heads Up Display (HUD) Control for Nerf Vulcan Sentry Gun
5 years ago
can it fit for another weapon
6 years ago
Awesome gun experiment .
6 years ago
Very cool! I am glad, I could inspire you!