A great way to get into robotics and
Arduino is by purchasing an Arduino kit. This comes with an Arduino microcontroller as well as a bunch of peripheral devices and sensors to help you learn tons and build a few cool things as well. I would greatly recommend getting ahold of a key other key items that likely won’t come in an Arduino kit:
· soldering iron
· heat shrink
· female jump cables
· Small point screws
· Hot glue gun
· Rubber bands
These items will allow you to get away from the breadboard and build something that stays together permanently.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Inspect the Kit
Inspect your Arduino kit. My favorite is the Inventor’s Kit by
Sparkfun, but many others will have similar stuff. Locate the key items that we’ll be using for this Instructable
· LEDs (lights)
· Tiny speaker
· 330 ohm resistors (or 220 ohm)
· Male Jump cables
· Servo motor with plastic armature
· LCD screen
There are several other parts in your kit that could be incorporated into your robot, but we’ll try to keep things fairly simple.
Step 2: Robot Base and Body
Create a base and body for your robot. I am super lucky and have access to a laser cutter and 3 mm plywood. Thus I designed my robot body with CAD and cut it out. You could to the same with cardboard. Make two holes for LEDs and one for the speaker. Keeping these close together can be helpful to reduce excessive wire lengths. Cut a rectangle for the LCD screen.
Screw your body onto the wooden base, and then attach the Arduino to the base. Be sure to leave the Arduino ports for computer and power accessible.
Step 3: LED and Speaker Circuit
Create a circuit for the LEDs and speaker. Solder a wire onto the negative leg of the speaker and the short (negative) leg of each LED. Black colored wire is traditionally used since this will be for grounding. Solder the 3 ends of the black wire together and solder half of a male jump cable to this.
Cut off the end of a colored male jump cable. Solder the remaining wire to the positive end of the speaker. Solder a 330-ohm resistor onto the long leg of each LED. Then solder a cut male jump cable (of different color) to each resistor.
Test this circuit. Connect your Arduino to your computer via USB cable. Plug the black jump cable into one of the 3 ground pins (GND). Try plugging each LED jump cable into the 5 Volt pin (5V). They should light up. For the speaker, touch its jump cable to 5 Volts for an instant and then pull it back out. You should hear it click. If any of these don’t work, check to make sure your soldering joints are good and that your LED is not backwards.
Step 4: Operating LEDs and Speaker
Add the LEDs and speaker to your robot. Use hot glue to stick everything in. Plug the black wire (for all 3 devices) into GND. Plug the positive speaker cable into pin 8. Plug the LED cables into pin 6 and 7.
Below are links to sample codes via Gist / GitHub. You can copy them and paste them into an Arduino file.
To copy the code from the Gist, hit the button on the upper right that says, "Raw." Then select all and copy. In a new Arduino file, delete all text/code that is already present. Paste in the code from the Gist.
Try this sample code to make the LEDs light up. Manipulate this code to make the LEDs light up in any way you want.
Try this sample code to make your speaker work.Manipulate this code to get different notes and timings.
Try this code if you want to hear the Mario song. (main theme and underworld, combined)
Step 5: Servo Motor
Connect male jump cables into the female ports of the servo motor. Use colors that match the wires on the servo. Plug the black into GND, red/orange into 5 V, and the white wire into pin 9. Press one of the plastic arm holders onto the servo.
The servo can be positioned between 0 and 180. Manipulate the code to change the positions it goes to, and the time it stays in those positions.
Use hot glue to stick the servo onto your robot. This could be as an arm, antennae, or whatever. Using a light material, cut out a shape (such as a hand) to accentuate the motion of the servo.
Step 6: LCD Screen
This is where it gets tricky, especially in terms of wiring. The LCD screen is easily connected via a breadboard, but we don’t have room for that on our robot. Mentally prepare yourself for some wiring wizardry. I recommend that you disconnect the LEDs, speaker, and servo from your robot until after you get the LCD working.
We’ll basically be using this wiring diagram to connect the LCD directly to the Arduino, but without a breadboard.
Using a soldering iron, along with male and female jump cables, create a common ground for all negative (black) cables.
Using red cables, make a similar situation for all the 5 Volt wires needed. I put in an extra male cable that will connect to the servo motor.
Connect all these red and black cables to the appropriate pins on your LCD and Arduino. I used this wiring guide (link) from SparkFun. Find the small potentiometer (blue in my case) in your kit. Connect this to the appropriate red and black cables. I tape the three potentiometer cables to each other for moral support.
For most of the remaining wires, you’ll need to stick together a male cable (for the Arduino) with a female cable (for the LCD). If you match color with the wiring diagram, you’ll find it easier.
When all LCD wires are connected and plugged in, you should see the LCD light up.
Here is a link to a “Hello World” code.Send this to the Arduino. Turn the potentiometer to adjust contrast and hopefully make the message show up.
Here you can make your LCD tell a joke about bicycles. I think this can give you a good idea of how the coding works and how to change it to say whatever you want.
Step 7: All Together Now
Time to put all the parts together! Reconnect the LEDS and speaker in the same manner as before. For the servo, reconnect the white (or yellow?) and black wires of as before. However, you’ll notice that the red wire conglomeration that you made earlier already takes up the 5 Volt pin. I included an extra red male pin on that system. Plug that into your servo and it should come to life.
Here a link to code that puts everything together. It makes the LEDs flash. The speaker plays a few notes, the Servo moves, and the LCD says a basic message. Change it up to make it your own.