Have you ever wanted to build a robot AND be a shark at the same time? Don't know where to begin? That’s okay! We all have to start somewhere!
In this beginner’s Arduino tutorial, I will be leading you through the basics of setting up your Arduino and building your first project - a robotic shark fin!
Step 1: Gather Your Materials
- 1 x Micro servo motor (should include both plastic servo horn and screws)
- 1 x Arduino Uno
- 1 x USB 2.0 Cable Type A/B
- 3 x Jumper Wires (red, white, black)
- 1 x 9V battery
- 1 x 9V battery clip with DC barrel
- Double sided tape
- Hot glue gun/sticks
- 2 x .5” Machine screws and nuts
- 1 x piece of foam board (3” x 5.5”)
- 1 x 2” popsicle stick
- 1 x Strip of fabric (36” x 1”) NOTE: This piece will act as a headband for you to mount your shark parts. If you have an actual headband, you can use this instead.
- 1 x marker (shark colored)
- 1 x piece of poster paper
Step 2: Set Up Your Arduino
Before you can begin running code on your Arduino, you have to download the Arduino IDE and install it on your computer.
The Arduino IDE is the environment you can use to write and upload code to your Arduino.
Here is a link to both the software and a comprehensive setup and troubleshooting guide.
Step 3: Building the Fin
In this step, we will assemble the individual parts needed to build the robotic fin. Here we will create the shark fin, cut out a base for your Arduino and 9V battery, and attach everything to your headband.
To create the parts for the fin, cut two equal triangles from your poster paper (base width - 3.5”, height - 3”)
- Once the pieces have been cut, color the fins using your shark-colored marker.
- In order to attach the fin to the micro servo, drill two holes in the end of your 2” popsicle stick according to the holes in your plastic servo horn. Once your holes are drilled, you will be able to attach your popsicle stick to the servo horn using the screws that came in the servo package (See above images for reference).
- Finally, glue your two triangles together with the color side facing outward, and, using double-sided tape, attach your fin to the popsicle stick.
- Mount the Arduino and 9V Battery:
Now, we will need the piece of 3” x 5.5” foam board you cut in the step “Gather Your Materials.” This piece will act as a mount for both your Arduino and 9V battery, and it will provide a barrier between your Arduino and your head.
- Using double-sided tape, attach your Arduino and 9V battery to the foam board. (For exact placement of parts, refer to the image above).
- Mount the Shark Parts to the Headband:
Finally, it’s time to attach the parts you just assembled to your headband (For exact placement, refer to the image above).
- First, we will attach the fin. You can do this using hot glue. NOTE: Make sure your servo is placed in the center of the headband, so when you put it on, the fin will sit at the middle of your head.
- You can attach your Arduino and 9V battery to the headband by drilling two holes at the top of the foam board and securing it to the headband using machine screws.
Step 4: Wiring
In order to power and control your servo motor, you will need to use the three wires coming out of it. Each of these wires serves a different purpose and cannot be interchanged.
Red Wire - this is your power and will require 5V.
Brown Wire- this is your ground and provides a return path from the current that came in through your power wire.
Yellow Wire- this is your signal and allows your Arduino to send information to your motor, telling it how to move.
- Using a red jumper wire, connect the servo’s power to the pin on the Arduino labeled 5V. NOTE: it is best not to power too many objects from your Arduino as it could overload and break. When you begin to use larger parts that require more power, you will need an external power source.
- Using a black jumper wire, connect the servo’s ground to the Arduino pin labeled GND.
- Using a yellow jumper wire, connect the servo’s signal to the pin labeled 9 on the right side of the Arduino.
NOTE: The pins lining the right side of the Arduino are referred to as “digital output pins” and provide information to your motors. In this tutorial, we are using pin 9 because it is specified in the code, but hypothetically, you can change this number in order to use different digital output pins.
Step 5: Upload the Code
In this step, we will be downloading the file containing the robot's code and uploading it to the Arduino.
- Download and expand the file “Shark Code“. Here you will find the code you need for your shark fin.
- After connecting the Arduino to your computer using a USB 2.0 cable, you will need to specify your Arduino’s port in order to properly upload the code. The port refers to which USB outlet the computer is sending information to. You can access the port preferences by opening up the tab, “Tools >> Port” in Arduino IDE. Your port is typically the last option listed and should look something like the port name in the image above. Select this port, and click the upload button in the Arduino IDE.
- Once the code uploads, you will notice the motor beginning to move. The Arduino will remember this code even if it is not connected to the computer, so once you unplug your Arduino, you can power it by connecting it to the 9V battery.
NOTE: never connect wires to your Arduino while it’s plugged in.