How to Make a Human Seeking Nerf Auto-Turret Robot

by donutsorelse in Circuits > Robots

3157 Views, 18 Favorites, 0 Comments

How to Make a Human Seeking Nerf Auto-Turret Robot

Making a Nerf Auto-Turret for a Tank Robot (Seeks Humans)

Welcome to the party pal! Here I'll be showing you how to build your very own robot that can track and target humans using a DIY Nerf auto-turret. This robot is perfect for anyone who is interested in robotics, electronics, or just wants a fun weekend project. We will be using a DF Robot Tank Devastator as the base for our robot, and outfitting it with a HuskyLens for the object detection and targeting system. Let's get started!

Supplies

Here's a list of supplies you will need to make your own human-seeking Nerf auto-turret robot:

  • DF Robot Tank Devastator
  • Romeo BLE Microcontroller (or some type of Arduino - this is just the one I used)
  • HuskyLens AI Vision Sensor
  • Nerf gun (I used a cheap Nerf Machine gun from target)
  • Servo motor (a powerful one if you're using the same kind of nerf machine gun I did!)
  • Jumper wires
  • USB cable
  • Power supply for the Romeo BLE Microcontroller
  • Screwdrivers (Phillips and flathead)
  • Optional: 3D printer or access to a 3D printing service to print parts if necessary
  • Optional: soldering iron if you need to make custom connections

Please note that you will also need a computer with the Arduino IDE installed, as the Romeo BLE uses the Arduino IDE to program it.

Nerf Logistics

These will change slightly based on the type of nerf gun you get, but not by much. So long as you pick a nerf gun that can fire multiple shots one after another before needing to reload, we'll just be communicating with a servo to make that happen.

If the nerf gun only requires pushing down the trigger, that's easy enough. We just need to mount the servo such that when it rotates a certain amount it pushes down the trigger and either hold it down or repeat the process based on how the nerf gun works. Mine was a bit more complicated, and required the trigger to be held down to allow for rapid fire, and then a mechanism on top needed pulled back and forth. This is still able to be accomplished with just a servo (though mine needed a more powerful one).

This is the nerf gun I used, but I honestly would recommend looking for a different one for your project. It's big, which is fun, but even that aspect was a bit tricky because it really weighs down the tank robot. The bigger issue, though, is it requires a lot of force to pull back the triggering mechanism far enough to actually fire.

The Nerf Gun Is.... Fully Operational

Mount the servo motor on top of the tank, in a position that allows the Nerf gun parts to still move correctly. This can be done by using screws or a 3D printed mount. Make sure that the servo is secured in place and that the arm of the servo is connected to the trigger of the Nerf gun. Once the servo and Nerf gun are mounted, test the rotation of the servo by connecting it to a power source and making sure that the Nerf gun can rotate to different angles. If you don't have 3D printer or access to a 3D printing service, you can use alternatives methods like using adhesives, clamps, or even hot glue to fix the servo and nerf gun in place. As you may have noticed if you watched the video at the start, this is a just for fun project and I want the servo back at the end of it so I just used duct tape. It may be a little silly looking, but it works!

If your gun has the same kind of mechanism mine does, you may need to get a bit creative. I tend to go overboard when it comes to repurposing things and ended up using a pole and a socket cover (actually), but the idea can be using in a much more normal way. The idea is just that the pole needs to be able to push and pull the mechanism, but would be resting up against different parts of it so we can't just adhere them together. As such, having something for the pole to move within like the socket cover made it so that the pole could move up and down due to the angle while still pushing and pulling effectively. To accomplish this without such an odd-looking combination, you could use something like a thinner pole (like a tent stake) and a circular metal piece like a decent-sized washer.

The code for the servo depends on your setup, including the angle needed, but all I needed to successfully fire my nerf turret was the little snippet below:


void fireNerfGun(){

myservo.write(130); // tell servo to go to position

delay(1000); //Wait briefly

myservo.write(50);

delay(1000);

}

Setting Up the Huskylens

The HuskyLens acts as the eyes for the tank and the nerf turret alike. The code is attached in the next step, but let's work on getting to that phase by setting up the HuskyLens!

A lot of what I'll reference below is found in the wiki (found here - https://wiki.dfrobot.com/HUSKYLENS_V1.0_SKU_SEN0305_SEN0336), but I'll include the steps to get started here for convenience:

  • Download the HuskyLens Uploader. Click here to download it.
  • Download the USB to UART driver, and install it. Click here to download it.
  • At this point you should be able to plug your HuskyLens into your computer via USB.
  • Run the HuskyLens Uploader, a small black cmd window will pop up first, and after a while, the interface window will appear, then click the "Select File" button to load the firmware.

  • Click the "Upload" button and wait till it finishes.

When it finishes, so long as it's plugged in it will be able to be used to switch between different modes by moving the rotator on the top and pressing the button. It can detect faces and such without modification.

Per the HuskyLens wiki: The R and T pins of HuskyLens (their functions are SCL and SDA here) are connected to the SCL (P19) and SDA (P20) pins of the micro: bit respectively. The communication protocol between HuskyLens and micro: bit is I2C.

Now for a bit of fun. Navigate to the Object Tracking section on the HuskyLens and teach it what you look like. I did this close range, but it'd be easier with a second person.

Now that we've made it this far... it's time to make the HuskyLens guide a tank robot armed with a nerf turret to hunt us down!

Assemble!

The same microcontroller (in this case a Romeo BLE) will control both the tank robot and fire the nerf turret. I modified the example HuskyLens code that is set to have a robot follow the object it's tracking such that the nerf turret will open fire whenever it sees the target (sometimes it will move to look for the target but won't see the target at that moment).

If your robot isn't already assembled, begin by putting together the Tank Devastator according to the instructions provided in the package. It's, thankfully, pretty painless. Be sure to get the code uploaded to your microcontroller before you put the top piece of the tank on, though!

The HuskyLens comes with an attachment that can be used to adhere it to the Devastator, but I used mine to put it on the front instead of the top so that there'd be room for the nerf gun. This will likely work well for your solution as well, since the top of the tank is the most intuitive place to house the nerf gun.

Lastly put the nerf gun on top and connect everything together! The code assumes that the servo is connected to pin 2.

Run!

nerf turret.png

The robot is after you! Kidding. Maybe?

Either way, it's time to enjoy evading your new robot overlord, or sending it after your friends. Have a good one!