Introduction: How to 3D Print Your New Best Surfer Friend
[This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com)]
If you have ever asked yourself any variation or combination of the following:
- "I wish my friends were cool."
- "I wish my friends were surfers."
- "I just wish I had some friends."
then you are in the right place! Why settle for boring real life friends when you can 3D print your own surfer friend? Do your friends ever say annoying things to avoid hanging out with you like:
- "Sorry I gotta work."
- "Sorry I gotta clean the house."
- "Sorry I'm going on vacation with my family."
or any other lame excuses, then look no further. Introducing Tom the plastic surfer. Why Tom? Because Tom is an awesome name. Tom is a loyal friend who's sole existence is dedicated to being your best friend. He doesn't have a family, responsibilities, a girlfriend (or boyfriend), or anything else to do besides be the best friend a guy could ask for. So keep reading, and I'll show you how you too can have your own Tom.
Step 1: Step 1: Building the Parts
What would this project be without Tom himself? That's why we are printing Tom first!
All of the parts of this project are 3D printed, except for the box. The box was provided as a part of the project kit I purchased for a university course. However, the CAD files for the box are available for you to print your own box. The wave, surfer, and surfboard were all created using AutoDesk Inventor and saved as .STL files. The .STL files can be imported into the MakerBot printer software directly and printed from there. The image above shows Tom ready to print in the MakerBot software. Printing times range from 30 minutes to 14 hours, so make sure to dedicated a good amount of time to printing. I recommend printing Tom first so you have someone to hang out with while you print everything else!
Step 2: Step 2: Building the Circuit
So now that you have all your parts printed (and have had plenty of time to bond with Tom) you are ready to build your circuit. You will need the following parts:
- 1 Arduino Uno
- 1 proximity sensor
- 4 LEDs
- 1 220 ohm resistor
- 1 stepper motor
- 1 breadboard
- Lots of wire
- And don't forget Tom!
First off, let's add the proximity sensor. There are 4 pins on the proximity sensor. The outside 2 are the echo and trigger pins. The inside 2 are the power and ground pins. (Note: In the image above, the software used to model the circuit only had a 3 pin sensor, so the power pin was left out). Hook up the echo pin to Arduino pin 7 and the trigger pin to Adruino pin 6 using wire. Wire the power pin to the positive rail and the ground pin to the negative rail. While we're at it, wire the negative rail to the Arduino ground pin and the positive rail to the Arduino 5V pin. Now the breadboard is connected to power and the proximity sensor is installed.
Now let's connect the stepper motor. The motor has 4 wires. From left to right, connect the wires to Arduino pins 10, 12, 11, and 13. This motor will facilitate the movement of the surfboard.
Finally, let's connect the LEDs. They will be connected in parallel. Wire Arduino pin 4 to the breadboard. Now, add a 220 ohm resistor connecting the wire from pin 4 to an adjacent breadboard pin. Now, put each LED next to each other on the breadboard, with the first LED's positive pin connected to the resistor. Connect a wire from the resistor to each LED's positive pins so that each LED will be powered by Arduino pin 4. Finally, wire each LED's negative pin to the negative rail. Now we have a complete circuit!
(Note: once you have the circuit working and connected, you will want to extend the range of the LED's by putting a wire between the LED pins and the breadboard so they can be mounted away from the breadboard.)
Step 3: Step 3: Running the Code
So now that you have all of the physical components ready to go, let's focus on the code used to power this contraption (by the way, I hear Tom is really good at coding.)
Starting with the first image, let's run through the code and see what each piece accomplishes. First we have our definitions. We define both proximity sensor pins, all 4 stepper motor pins, and the LED pin. Lastly, we define delaytime as the delay in ms between each coil activating in order from A to D (more on this later).
Now on to the setup. We start by activating the serial port, which will read out the distance values from the proximity sensor (because why not!). Then, we define the echo pin as an input and the trigger pin as an output. We also define all 4 stepper motor pins as outputs, and the LED pin as an output. So the only input we have into the circuit is the echo pin.
Moving on to the second image, the void loop. The first chunk of code tells the proximity sensor to read values and convert the pulses to distance values in centimeters. Then, we have an if else statement which states that if the distance is less than 15 cm, to activate the stepper motor. Now the else part of the code uses some functions defined in another code file. This file is shown in image 3 and 4. It essentially defines Step A through D as the activation of one of the 4 coils inside the motor. Then, when we reference the function "forward()" the coils activate in order from A to D, with a delay equal to "delaytime" which was defined earlier. The lower the delay, the faster the motor rotates because the coils activate faster. The function "backward()" activates the coils from D to A, rotating the motor the opposite direction. Now, moving back to the else statement. Firstly, as long as the distance is less than 15 cm, the LED's will activate. To determine how far the coil rotates, we define a variable called "numberofsteps" which defines how many times the forward or backward function repeats. With the value at 50, the stepper motor goes through 50 forward cycles, pauses for 10ms, and goes through 50 backward cycles. While the motor is moving, the LEDs remain lit.
Step 4: Step 4: Bringing It All Together!
Tom is ready to catch some waves! Let's start by drilling some holes in the box. We need 2 holes in the front to mount the proximity sensor, one in the back for the USB cable, one on the top middle for the wire from the stepper motor, and 4 small holes on the top front to mount the LEDs. Now, we put all of the internals inside the box. Push the LEDs through the holes so they fit snugly and stay in place. Now, feed the stepper motor wire through the hole into the box and connect it to the Arduino. Put the wave on the top of the box and install the stepper motor inside the wave. Finally, we mount the surfboard to the stepper motor and Tom to the surfboard. Tom is finally ready to surf! Just plug in the USB cable to your computer, upload the code, and put your hand in front of the proximity sensor. You'll find that Tom is a great surfer! Enjoy your new best friend!
We have a be nice policy.
Please be positive and constructive.