TERROR-MI Motion-activated Vehicle Project With Arduino Uno
by generalalphon in Circuits > Robots
238 Views, 0 Favorites, 0 Comments
TERROR-MI Motion-activated Vehicle Project With Arduino Uno
Welcome to Project Terror-Mi!
Video: https://drive.google.com/file/d/13562m5wpYHADrdWaDxHXN4YHXUA0v7NC/view?usp=sharing
A scrappy school assignment executed by a complete beginner in Arduino and electronics turned into a makeshift gag contraption with a very simple basis. Despite its faults and its turbulent design and production, I believe it to be a wonderful showcase of the fact that anyone can make anything. Talent is only optional- one needs only interest and a bit of effort to learn a new skill, to create something from nothing, and I believe that to be very inspirational!
The Terror-Mi is a large LEGO-built vehicle equipped with a motion sensor. Once it senses a target walking in front of it, the motors activate and the vehicle attempts a vain, pathetic attempt to ram the unfortunate soul before it. Glory to Miiii!
Supplies
Required components:
-Experienced Terror-Mi pilot (small plush) (The small Anthrax plush I use is no longer being sold)
[https://www.giantmicrobes.com/us/products/anthrax.html]
-Arduino Uno
[https://store.arduino.cc/collections/boards/products/arduino-uno-rev3]
-Arduino Motor Shield
[https://www.amazon.com/HiLetgo-Driver-Shield-Compatible-Duemilanove/dp/B01DG61YRM]
-DC Motor x2
-PIR Motion Sensor
-Jumper wires (Three Male to Female)
-Lots of bricks!
-Two wheels
-M3 screws (depends on chosen wheel)
-A box full of bricks to build your Terror-Mi with!
-A battery (9V) or power bank to power your Terror-Mi with!
Note:
-If you buy any components, don’t use these links! Find local stores to be off a lot cheaper!
Required tools:
-Soldering equipment
-Screwdriver (3mm)
-Depending on your chosen wheel, something to punch a hole through your wheel!
Note:
-This is a detailed walkthrough of my own rendition of the Terror-Mi. Sadly, the end product did not end up functioning fully as intended due to a defective choice of wheel and a multitude of wiring-related issues. In addition, the battery did not function as intended with my Arduino… If you want to make a Terror-Mi yourself, you can follow all the steps in this guide, though you’ll have to pick a better wheel for your DC motors!
Programming Arduino
With our components ready for later, it is time to investigate how the programming of the Terror-Mi will function. Luckily, this is relatively simple- it can even be described in a single sentence!
IF SENSOR, THEN MOTORS.
If the motion sensor outputs activity, the motors turn on and move the vehicle forward, then go off again when motion activity disappears. Keeping this schematic at the back of your mind simplifies things while programming.
To begin programming, open up your Arduino IDE. For the DC motor used for this project, a library is required, which you can install by simply searching for it at the IDE’s library screen: Adafruit Motor Shield library (version 1, not version 2!)
Then, we can begin coding!
#include <AFMotor.h> //This library controls our motors
AF_DCMotor m1(1); //We define the motors here!
AF_DCMotor m2(2); //The number in parentheses refers to the connected ports!
int sensor = 2; //This is the pin number on which the motion sensor will read!
bool run = true; //This testing variable controls whether to activate motors!
int val = 0; //This variable is used to track the output of the sensor!
void setup() {
pinMode(sensor, INPUT); //This makes the Arduino recognize this pin as input
Serial.begin(9600); //Used for decoding
Serial.println("Startup complete.");
m1.setSpeed(255); //The motor speed is a number from 0-255. We want speed!
m2.setSpeed(255);
}
void loop() {
val = digitalRead(sensor);
//val = HIGH;
if (val == HIGH) {
Serial.println("Motion!");
if (run) {
m1.run(FORWARD); //FORWARD makes the motors run forward!
m2.run(FORWARD); //”Forward” is defined by polarities. If your own motor does not go forward but backward, //you can change this to BACKWARD or switch your wires around.
}
} else {
Serial.println("No Motion!");
if (run) {
m1.run(RELEASE); //RELEASE makes the motors stop!
m2.run(RELEASE);
}
}
delay(250); //The next Loop will happen in 250ms. This means that our Loop function triggers 4 times per second.
}
Downloads
Wiring
Now that our code is ready, we can start wiring our machine up. The theory, again, is quite simple. See the diagram of the wiring.
Green and red connections are + and - connections for power. The PIR Sensor also outputs a voltage based on its sensor input, which is connected to the Arduino (through the shield, which lies on top of the Arduino).
Note that during testing, we won’t need the 9V battery yet.
While easy in practice, the wiring can be quite problematic. Personally, I had a plethora of problems with getting the screw monitors stuck properly. Before starting, make sure to prepare:
-Get your soldering tools and screwdriver ready!
-Strip the wires attached to your DC motor, so that a large amount of copper wiring becomes visible! If you do not have an express wire stripper for this, use scissors or preferably, a box cutter.
-Attach the motor shield to your Arduino Uno.
Then, the wiring can begin. First comes the PIR sensor. Make sure to double-check online which of the three wires correspond to which for the model you’re using. For the model I used, when the pins are at the left-facing side of the sensor, the top wire is +, the bottom wire -, and the center wire the output.
Pins on the Motor shield correspond to the Arduino pins below them. Solder them together so that + connects to 5V and - connects to GND to supply power to your motion sensor. Then attach the middle wire to your Sensor pin. This can be any digital pin, but with our programming, we’re using pin 2.
You can test whether this is functioning properly by turning the Run variable in our programming off and watching the Arduino’s serial output. The PIR sensor is very sensitive, and will spot infrared changes in a ~160 degree of vision up to ~5 meters away! I tested it by putting it in my pencil case, facing away from me, using my finger to trigger it.
Then, it is time to attach the DC motors. These are attached through screw monitors corresponding to the M1 and M2 sections of our Motor shield. Screw monitors work with a screw that pushes a wire downwards onto the metal, making soldering not required.
You can see it on the pictures of my own wiring!
When you attach a battery, you do so through the top-facing two screw monitors of the Motor shield using similar methods.
Now, you can test the workings of your system. With the Run variable set to True, your motor should be rotating now whenever the PIR sensor reports activity!
Chassis & Wheels
Now the most fun part of all begins. LEGO construction!
For this part, I used LEGO from my childhood for an extra dose of nostalgia. You won’t have to be precise while building- you’ll just have to make sure to complete a few important objectives:
-The Mi needs a place to stay, stably so without falling over
-The PIR sensor needs to be able to face forward, without being triggered by events that happen to the vehicle’s sides. It must also be able to connect to the Arduino.
-The vehicle needs a housing for your Arduino, and a resting place for the engines. You’ll also want a free spot for a battery, or an open port to attach your Arduino to your laptop even while inside of the Terror-Mi.
-The engines must face outwards, and the wheels must reach the floor from them. They must also be able to connect to the Arduino.
Personally, I achieved this by building a relatively long vehicle supported by tiny but strong LEGO wheels, with the motorized wheels at the very back. I covered the vehicle up to give it a finished look. The PIR sensor fits perfectly in a 4x2-brick-sized hole, allowing it to stay with the Mi at the front.
The Arduino and the Mi rest on sloped LEGO blocks that keep them in place during mild turbulence. The motors were harder to stabilize- I surrounded them with LEGO from all sides to keep them straight.
Another important task is choosing a wheel for your Terror-Mi. You’ll want a strong wheel that can support the weight of the vehicle- but it doesn’t have to be an industrial-duty super-wheel. The goal of the Terror-Mi is to watch a funny creature try to ram someone- I’ve even iterated using a large plastic rod to inch the vehicle forward!
The Pringles-can wheel I used was attached into the engines by poking an M3 screw straight through it, which perfectly fits into the DC motors.
Aftermath- Design Process
The creation of the Terror-Mi was the product of a short design process. It all started with my Mi- the name I had given the plush that had become my mascot. In reality, a Mi is a small Anthrax plush from Giant Microbes, who make plushies based on various organisms tinier than what the eye can see. Anthrax is a dangerous bacteria-based disease known for its use as a bio-weapon, due to its ability to create very long-lasting spores that can survive in resource-scarce environments for decades.
So why do I call my Anthrax plushie a Mi? Don’t ask. I don’t know. But here it is. Mi! And it has the personality of a devious little gremlin soldier, which was the base of inspiration for the Terror-Mi. I wanted to create something that the Mi would be able to use as equipment.
Here are various design posters I made to highlight these steps:
Aftermath - Reflection
As a long-time game programmer, I was very enthusiastic to try my hand at a system that would have a real-life, physical implementation instead of a digital one. Sadly, my luster did not last long. Though I firmly believe the theory of my Terror-Mi is easy, in practicality, nothing worked out for me!
At first, I had to wait very long for supplies to arrive, which limited the time I had to complete the project (being a school assignment).
My motion sensors seemed to produce incoherent results. At some point, my Arduino was detecting random inputs- even with *nothing* plugged in at all! I got a graduated electrical engineer to look at my designs, but even he was stumped with what exactly was wrong. I was not able to find any sort of diagnostic tool to check my Arduino board for faults or inconsistencies.
When the PIR sensor decided to work (for unknown reasons!), I was stuck for weeks at the motor phase of my project. The motors, which were attached through screw monitors, would constantly stop working or work unexpectedly. This likely had to do with faulty wiring not properly connecting to my Arduino board- but it seemed simply impossible to make it work! I’ve been fiddling my hands for hours on end, optimizing the placement of those demonic four wires, hoping that they’d finally work this time. And when they wouldn’t work, I would walk away from my project, only for the motors to magically activate ten minutes later without anyone touching the machine, as if possessed! And then they’d stop working again if I’d do as much as breathe too harshly near the wires. My self-pity parade doesn’t end here (I am sorry folks, but noting this increases my chances for the school assignment): But even Instructables didn’t allow me to post any images along with my text, making even the presentation of my documentation sub-par.
I didn’t feel like I learned anything- it felt as if my project was simply in fate’s hands.
Due to these troubles, I was never able to properly work on the fun parts of my projects. I wasn’t able to trial-and-error with my choice of wheels, either- the Pringles wheels did not work out as they were too light and flimsy to support the full weight of my vehicle.
Overally, for me, it was an arduous experience. Normally I would say that breaking out of my comfort zone is refreshing, but in my case, it has only brought me frustration. I do hope that my process, insights and journey can help another, or least show to another student that they’re not alone!