Introduction: Portal Two Sentry Turret by Arduino Uno
This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com)
Step 1: Code
The code is no more complex than a few if-statements and
knowing how to write to the Arduino Uno components.
The major components of the code are usually directly related to the hardware: a PING sensor, a few LEDs, a speaker, and a Servo motor essentially dictate the entirety of the code. There is a library included for the servo motor as well as a timesTurned integer that counts up how many times the turret has shifted its position in search of an object.
With regard to the hardware, the PING sensor is like the driver of the code because the condition of all of the if-statements is based on what the Arduino is reading from the sensor. So whether or not the PING sensor notes to the Arduino that it “sees” something within 30 cm or when it doesn’t find anything within that range is going to determine what happens next within the code due to the if-statement.
If it sees something the LEDs are written to high in a pattern so that they light up and the speaker sounds as well. The servo stops turning for these actions.
If it doesn’t see something the servo is written to move by increments of ten based on a pos, position integer written into the code that always counts up or down depending on which direction the bot is moving. Writing this position in the sense of degrees is made easier by the library.
Step 2: Modeling (Solidworks)
GrabCad had a few models that would be great to scale down
and use. I couldn’t figure out how to do this however and ended up sketching my own. It’s an awkward, organic shape so sweeping cuts and extrudes about a curve became an important part of the build. The body is the main central shape with two wings that are the same part but mirrored, there are two wing supports that need to span from the top or bottom of the inside to about halfway in order to leave space for wires and lastly there is the servo mount which I used convert entities from the bottom of the body to create the right curve for. It’s easiest to see all of these working together in the photo.
Step 3: Printing
This can take patience depending on what printer you’re
using and how comfortable you are with it. My turret body print is a six hour print and each of the wings is about four and a half hours without any failure. I saved each of the Solidworks files as a .STL and then used the FlashPrint program and the Forge Finder 3D printer. Pretty straightforward prints. Supports are a good idea and be weary of running out of filament halfway through because that can ruin a day.
Step 4: Assembling
Servo prep. I used a few well-placed drill holes and a box
knife to remove the plastic for the servo motor to sit in. Be sure to keep the fit snug. Once that’s done place a depth that isn’t going to cause the wings and conflict with the box and screw a metal plate in underneath shimmed with washers that will hold the servo.
Box prep. One big drill hole in the side let me run the Arduino wire out of the project and to my computer for extra power. At the back left corner of where the body sits on the servo I drilled a sizable hole to run all the wires into so that they would be clustered together to give it a cleaner look but also be sure everything can reach.
Body and wings. Start by hot gluing the head side of a screw that’s long enough to reach into the body on to the center of each of the wings. Hot glue the two mounts so that the holes face toward the wings and be sure to position them so that the wings can rest comfortably in a slightly open position. I took a toothpick and wedged it into the eye socket so that it would provide extra support to the PING sensor. It landed just about the center and I painted it black. The last part was the mount which had the servo portion placed into it and was hot glued to the project.
Wring. I ended up implementing a state of the art cardboard wiring harness for my project. Trace and cut out the shape for the body and the eye hole. Cut slits for the LEDs to slide into. I did mine in a four corners assembly. I painted my cardboard black for appearances and gently taped the wires attached to the LEDs in place.
The speaker nestles underneath the PING sensor, so underneath that toothpick from before. And the wires can be taped down.
For the eye cut a circle out of black cloth a little bit bigger than that of the eye hole. Cut two circles for the PING sensors into the larger circle you have now. Lay it over and using a knife, gently tuck the cloth behind the board for the sensor and underneath the speaker so nothing but the sensor is exposed.
Step 5: Circuitry
If printing didn’t test patience this step will.
I started by wiring the bulbs to long female adapter wires that way I could have them move freely as opposed to a breadboard. It’s important to be organized so writing down what color is polar on which bulb is a great way to accomplish that. I had everything written out starting by looking at the pin numbers from my code.
I plugged and taped everything on to the printed pieces and harness first before running all the wires into the hole at the bottom and plugging them into the breadboard and Arduino which lie nestled in the box. My breadboard and Arduino were placed in the box already wired together with ground and power.