Building a Team Fortress 2 Sentry Gun

Introduction

I’m a little artistic (autistic) nerd who aspires to express my creativity through my creations. I barely have any experience in robotics, I hate coding with a passion, but I’m familiar with 3D modelling because I have been using Blender, Source Film Maker, and also Roblox Studio in the past.

Ideas

Throughout the course, I only had a single idea that I committed to turning into reality because I wasn’t able to do this in my previous IoT course: a level 1 sentry gun from the hit game Team Fortress 2 that will track targets and then fire (play sounds and flash LEDs).

What did you need to learn

The goal of this project is to create a radar-like machine that will detect targets with a distance sensor and then play sounds and flash LEDs to simulate firing. For this project, I needed to learn a bit about the audio system of the ESP-32 and also how to use the distance sensor alongside a rotor.

The building phase

I started by testing the sensor and the motor. I tried making the motor work like a radar by rotating side to side, then retracting to the central position when the sensor detected something. With the help of ChatGPT for coding, a simple contraption like this could have worked perfectly. For the actual tracking, I had an idea about using the AI Thinker module to detect and track faces, then the distance sensor would be used for firing. However, this concept required me to use two different sets of code uploaded separately to two different modules, which I had zero idea about how to do. Thus, I spent weeks procrastinating and trying to make this work, only to ditch it when the deadline came close.

During the week before the deadline, I turned to testing the audio system by using an amplifier, a loudspeaker, and an SD adapter. This time, I turned to using Claude AI because ChatGPT was just too much of a dimwit when it comes to consistent and reliable code. At first, the audio files uploaded to the SD card did play, but they stuttered throughout the whole duration. Hence, someone suggested that I should reduce the size of the files and upload them directly to the ESP-32.

I tried doing that and then immediately gave up after one hour. At home, I asked Claude to fix the code a bit, and by some miracle, it worked wonders for me. The audio was playing perfectly without any stuttering, and the quality was extremely close to the original, albeit a little subtle. After that, I connected the LEDs and the motor to my contraption to simulate the finished product. However, it only worked with the USB cable connected to the ESP-32 and not the power cable I used.

In class, I tried a different adapter, but the capacity was still too weak, so I just ditched it and turned to using the ESP-32 to power everything (could be a fatal mistake, but if it works, it works). And then a sudden thought came crashing in like a truck, sending me to a parallel world.

I forgot that I had to work on the 3D case from this whole contraption. I intended to print a 3D model of the sentry gun, which I could find online while making the core to work, but my birdbrain just said “screw it” and decided to ignore the whole thing entirely. Thus, I turned to one of my most primitive skills, papercraft making.

I went online and found a papercraft template of the sentry gun for printing from over a decade ago, so I went with that. With hindsight, this was a better solution for a couple of reasons: I was too lazy to go to the lab and wait for hours to print a 3D case; making papercraft models takes way less time and is actually really fun; I hadn’t done anything creative in a while because I was so busy with classes and also hooked on games.

Well, darn it, did I just go and burn the sensor and probably some other components by foolishly plugging the amplifier’s GND to the 5V rail?

Monday finally came, so I went to class. I spent the whole day trying to get the contraption working again by replacing some parts and then assembling the remaining parts of my frame. The result was acceptable. I had to remove the piece of cloth to make the sensor work better, but overall everything else worked just fine EXCEPT for the motor. One fatal mistake I made was ditching the big motor and just going with the small one to save more space.

Consequently, the turret only rotated ever so slightly and barely made it over 30 degrees. I also had to use a metal wire to pull the barrel down because the rear was too heavy, so the whole thing was only aiming upward. And yes, there’s a secret button at the bottom that will activate Square Dance Mode when clicked.

The outcome

After this project, I learned that I should reserve more time for designing the frame and also choose the correct component. But all in all, I did learn a lot more about sensors, motors, and audio systems. I haven’t had a clear goal of what to build next, but I’m sure it will be silly and funky. Besides that, I still have that Kasane Teto robot in mind as my ultimate goal.

Github link: https://github.com/Tonkcode69/Level-1-Sentry-Gun/tree/main

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.