Introduction: Piranha Plant

This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com)

Now, most of us will recognize the one of the most famous plants from the Super Mario Bros. Series, but for those of us who don't it is basically a plant that pops out of the ground or a pipe and usually spits fireballs at you. Here we're going to show you how to 3D print one of your own, and make it so that it can shoot at your nearest plumber.

Step 1: Gather the Materials

Now, in order to make the piranha plant open its mouth and fire we will need to use a few electrical components. The list has been added below:

1 X Arduino Uno R3

1 X USB Cable

1 X HC-SR04 Ultrasonic Ranging Module

1 X SG90 9G servo

1 X Stepper Motor

1 X ULN2003 Motor driver module

1 X Mini-Breadboard

1 X 4pin IIC cable

1 X 220 ohm resistor

1 X 10k ohm resistor

1 X LED (Color of your choice)

1 X Button switch (or switch of your choice)

3 X Rubber bands

9 X Female to female cable (At least)

20 X Breadboard jumper wires (Around)

As you can see, we will be using an arduino in order to program all of this. If you're not familiar with this, don't worry, I'll be giving you the code to paste into it.

A few other things you'll need that aren't electrical are tape, krazy glue, regular liquid glue, fishing wire (or just really strong string), an electronics enclosure (I used the DC-47P), a drill, red/green spray paint, and white acrylic paint.

Finally, the fireballs that we will be using are just your standard 6 mm airsoft BBs. I used red BBs just because sometimes it is best to represent something with a color we all recognize it with.

Step 2: Time to Print

Okay, I have uploaded all the necessary .stl files needed in order to start printing. You're going to only need to print one of each file, except for the tooth file, that one you'll need 10. All the pieces are saved in inches, and the head is about 5 inches in diameter for reference.

While waiting for the prints, I would suggest drilling a few holes into the electronics enclosure in order to allow for the wires and the switch to go through. I drilled 3 holes on the top, 2 for the wires (about half an inch in diameter) and 1 for the LED (A little bigger than the LED). I also drilled 1 hole on opposite sides of the box (Also about half an inch for both of them), 1 for the USB cable and the other for the button.

Once you've drilled the hole for the LED and the button, I suggest placing the LED and button in their respective slot. You may glue them there if desired.

Step 3: Painting

This step is optional for some of the pieces depending on the color of the filament you were using. What I did was spray paint both the pipe and the head pieces. The pipe is the easiest since it's only a solid green color. The head pieces (base, top/bottom jaw) need to be painted red, and then we can start with the spots. I used white acrylic paint and just start painting random spots of different sizes wherever you like on them. After you have painted the spots, you paint the lips on the top/bottom jaw (this may need at least two coats in order to look nice).

The vine I did not paint, but that is because I had managed to get it printed with a green filament. If painting it I would recommend getting a lighter shade of green in comparison to the pipe. I would also recommend painting the teeth white, but that's up to you.

Step 4: Gluing the Teeth

This is a fairly easy step, just use the krazy glue to stick the teeth in their designated spots behind the lips of the jaw pieces. The top jaw has six holes and the bottom jaw has four. The image shown is just the teeth being held in by pressure, and it has yet to be glued in.

Step 5: Internals

Now we continue with the Internal Rack (labelled as Skeleton). This piece is placed inside of the Base and holds up everything. The large circular hole is for the stepper motor, and the rectangular hole is for the servo motor. On the top bar above these two holes is where the Pistol piece will hang (you'll need to glue this). Remember to put the Piston piece and to put the rubber bands between it and the Pistol before gluing it to the Skeleton.The two motors should be able to stay in place due to pressure, but can be glued there for good measure. Add the Peg to the stepper motor. The servo should have included its own one sided peg that you will be using.

The motor driver module can be put anywhere, as long as it's not in the way. Just be sure to connect the stepper motor to the motor driver module.

You should also tie two long strands of the fishing wire to the end of the servo peg, we'll cut off the excess once you've tied the jaws to them in a later step.

Once you've done that, it's time to glue the Skeleton into the Base. I used the standard Elmer's Glue-All (AKA school glue) on the round edges and then let it sit within the Base overnight to dry. You could just use krazy glue and then add the elmer's glue for good measure, but that's up to you.

Step 6: Vine Internals

This is going to take some patience. We now need to get 9 wires (3 male-male cables for the servo and 6 for the motor driver module) through the vine. The module could use the IIC cable or 4 female-female jumper cables, but it will need at least 2 female-female jumper cables to be used for power.

I would suggest getting a pair of tweezers to help you grab some of the cables.

Step 7: Label Your Wires

Before continuing, I would highly suggest labeling your wires, either with tape or any other sort of mark. This will make it easier to connect it to the arduino.

Step 8: Base Meets Vine

Now, we have to insert the Vine into the Base. Before doing it, remember to pull the fishing wire through the holes of both the vine and the base. We also have to connect the wires coming from the base to the wires in the vine, so do so now and make sure you labelled them correctly.

Once you have placed them correctly, you can glue them together to make sure they stay secured.

Step 9: Pipe

The pipe is really easy as far as circuitry goes. Get the HC-SR04 Ultrasonic Ranging Module and just tape it to the openings, you can glue it if you want but I used tape. Connect either the IIC cable or 4 female-female jumper cables and remember to label them (The pins are labeled on the USR module).

Now place the Base/Vine combination onto the Pipe. You can choose to glue it if you so desire at this moment.

Step 10: Wiring

This is where having really long cables comes in handy... and the labeling.

Pass all the wires through the top hole(s) of the electronics enclosure.

Start connecting the wires and make sure to follow up on the labeling. Several of the cables can be directly hooked into the arduino.

For the USR module: connect the echoPin to pin 5 on the arduino, and connect the triggerPin to pin 6 on the arduino.

For the servo motor: connect the yellow cable to pin 7 on the arduino.

For the motor driver module: connect int 1-4 to pins 8-11 on the arduino, respectively.

The rest have to be connected to the breadboard and then the arduino.

Before starting, remember to connect the pin on the arduino labelled 5V to the power section labeled + on the breadboard and the Gnd on the arduino to the - section. Do the same for the other power section, except use the pin labelled Vin as +.

For the cable connecting the button to the arduino, connect it to pin 2. View the image to see how to wire the button, also note that the resistor is a 10k ohm resistor. Depending on the type of button you get will determine how you connect it to the arduino. I had to use 3 female-female cables and then the jumper cables to connect it to the breadboard. Some buttons allow you to connect to the breadboard directly.

You will also have to connect the LED to the breadboard, you can do so by connecting the female-female cables to the ends of the LED and then connecting another cable to the breadboard. There is another image for how to connect the LED to the breadboard, except the pin to the arduino will be pin 12. The resistor used is the 220 ohm resistor.

As far as powering everything, the components that need to be connected to the Vin strip are the servo and USR module. The components that need to be connected to the 5V strip are the motor module and the button.

Step 11: Time to Test

We're going to test it out to see if everything is connected properly.

For the software, you will need to download the Arduino IDE which can be found here:

http://arduino.cc/en/Main/Software

In the zip file I have included the programming to be uploaded into the arduino. Please note that there is a libraries file in the zip file. The files in the library need to be added to the arduino library, which can be done by looking into your Documents folder, then into the Arduino folder, and finally into the libraries folder. That is where they belong. After doing that, connect your arduino to your computer and upload the PiranhaPlant file into it.

Place your hand in front of the USR sensor and see if the servo turns 180 degrees, if so then all is good... so far.

Now click the button, if the LED turns on then the interrupt is working. Click it again to see if it turns off. Once that happens, turn it back on and place your hand in front of the sensor and see if the stepper motor begins to turn. If that works then everything is properly connected. Otherwise, take a look at your wires to make sure nothing came loose.

Step 12: The Theory Behind It

Just so that you have an idea of what the program is doing we're going to look at the block diagram.

The program uses the USR sensor to take 3 individual measurements. When the first two measurements are within a certain range, the arduino activates the servo in order to open the mouth. After about 2 seconds, it then closes the mouth.

The third distance is responsible for the stepper motor, but can't be activated unless the safety switch is turned off. The safety switch is turned off when the LED light is turned on. When the safety is off and the third measurement is within the specified range, then it will activate the stepper motor which is the "Fireball" Launch Trigger. Essentially the stepper motor pulls back the Piston piece until it slip off the peg.

After that, it resets and begins taking the measurements all over again.

Step 13: The Code

For anyone who doesn't wish to download the file or just wants to know what they're getting before they get it, here's the code.

/******************************************<br>    PURPOSE:    Piranha Plant
DATE: 12/2014
*******************************************/
#include // Library for the proximity sensor
#include // Library for the servo
#include // Library for the stepper motor
#define gearratio 64 // 1:64 gear ratio
#define echoPin 5 // This is the echo pin
#define triggerPin 6 // This is the trigger pin
#define servopin 7 // This is the servo pin
#define ledpin 12 // This is the LED pin
Servo myservo; // instantiate a Servo object named 'myservo'
int x; // Integer used for 1st distance recorded
int y; // Integer used for 2nd distance recorded
volatile int z=0; // Integer used in the interrupt
const int stepsPerRevolution = 2048; // Number of steps to complete a revolution
Stepper myStepper(stepsPerRevolution,8,9,10,11); // Pins for the stepper motor
Piranha distanceSensor(echoPin,triggerPin); // The constructor to instantiate a sensor named "distanceSensor"
/***************************setup function*********************************/
void setup() {
Serial.begin(115200); // Start serial communication
myservo.attach(servopin); // Attaches the servo on pin 7 to the servo object
myStepper.setSpeed(0.8*gearratio); // Sets the speed for the stepper motor
attachInterrupt(1,Interrupt,RISING); // Attaches the interrupt to pin 3 and activates when it is rising
pinMode(ledpin, OUTPUT); // Sets the LED pin as an output pin
}
/***************************main loop**********************************************/
void loop() {
float distance1 = distanceSensor.readSensor(); // Here we call the 'readSensor' method to determine the distance
// and set it equal to distance1

if (distance1 > 0 && distance1 < 100){ // Here we set x=1 if the distance threshold is met
x=1; // Otherwise x=0
}
else {
x=0;
}

Serial.print("distance1: "); // Prints the distance into the serial monitor.
Serial.println(distance1);
delay(1000); // A 1 second delay
float distance2 = distanceSensor.readSensor(); // We take another distance measurement
if (distance2 > 0 && distance2 < 100 && x==1){ // If both the first and second distance are within the threshold
myservo.write(180); // it will activate the servo to the 180 degree position and set y to 1
y=1;
}
else { // If either the first or second distance isn't within the threshold
myservo.write(0); // the servo will return to the 0 position and set y to 0
y=0;
}

Serial.print("distance2: "); // Prints the distance into the serial monitor.
Serial.println(distance2);
delay(1000); // Another 1 second delay
float distance3 = distanceSensor.readSensor(); // A final distance measurement labelled as distance3
if (distance3 > 0 && distance3 < 100 && x==1 && y==1 && z==1){ // If all three distances are within the threshold and the interrupt
myStepper.step(stepsPerRevolution); // has been activated (thus removing the safety), it will activate
delay(2000); // the stepper motor and delay for 2 seconds before resseting the
x=0; // variables. Otherwise it will only delay for 1 second and start over.
y=0;
}
else {
delay(1000);
}

Serial.print("distance3: "); // Prints the distance into the serial monitor.
Serial.println(distance3);
}
void Interrupt(){ // This is the interrupt
z=!z; // This will make the variable that change to the opposite value
if (z==1){ // When z is equal to 1 it will turn on the LED pin to act as a
digitalWrite(ledpin, HIGH); // cautionary warning light saying that it is ready to fire
}

else {
digitalWrite(ledpin, LOW);
}
Serial.print(z);
}

Step 14: Finishing the Head

Now that we know that all the circuits are working, we can begin closing things up since we no longer have to work in those cramped spaces. The two jaw pieces are attached to the base by the pegs on the inside of the jaw into two of the four holes on the base. You will need to pull on the jaw a bit in order to snap it into place, but you should be fine.

Now, make sure that the servo is at the open position (peg pointing towards you if your looking at it) before attempting to tie the jaws to the fishing wire. Tie the fishing wire through the hole on the back end of the jaw in the open position. Once you tie it, glue it in order to prevent it from untying itself. Do this for both jaw pieces.

Now in order for the mouth to close, we need to put the rubber bands around the teeth at the ends.

Step 15: Sealing It Up

Now since everything is done, we can start closing things up. Screw the top of the electronics enclosure and begin to glue the Pipe on top of the enclosure. Make sure to hide all the wires.

Now you can glue the Vine to the Pipe if you haven't done so already.

Wait for the glue to dry, and now you're done!

Step 16: Plug and Play

Since the program has already been uploaded, now whenever you plug in the Piranha Plant to a USB it will automatically start taking distances and opening it's mouth if anyone is within range. Mind you, you will have to manually out in the "fireballs" into the pistol in its mouth if you want it to fire. And you have to take off the safety if you want it to fire.

I will be making some improvements on the design and posting them when I manage to test them out, but for anyone else who is capable of using 3D software, feel free to do so and share your results.

3D Design Contest

Participated in the
3D Design Contest