Introduction: R2D2 Robot With Bluetooth and Sound
This will show you how to create your own bluetooth-controlled robot with custom sound effects. As seen above, I fashioned mine to look like R2D2.
1 x Arduino Uno
1 x Adafruit Wave Shield (You will have to solder this together yourself)
1 x breadboard, a micro breadboard works fine
2 x Micro Metal Gearmotor (you can choose whichever one you liked, but personally my robot was slightly top heavy, so a higher rpm motor might be more trouble than they're worth)
1 x Dual Motor Driver Carrier (any kind should work, but connections will vary)
1 x HC-06 Bluetooth Module (any kind should be fine, they go for cheap on ebay. HC-05 should work fine as well)
1 x 9v Battery
4 x AA batteries (to power the motors in the Zumo chassis
You'll also need a smartphone to operate the robot via bluetooth.
Step 1: Assembly
You'll need to assemble your Zumo chassis and your wave shield kit. The Zumo chassis and the Wave shield have well-documented instructions on how to assemble them, so those shouldn't be to much of an issue.
My own robot was assembled using parts around the house and parts from an arts and crafts store. The body is an aluminum peanut can, and the top is a thin stainless steel bowl I got from amazon that just so happened to be same size as my peanut can lid. I cut holes in the bottom of the can to both mount it on the chassis on offsets, and to pass wires through for powering the motors and the arduino.
Step 2: Bluetooth Module
The bluetooth module is really simple to set up, but may cause issues if you don't connect it correctly. It should be powered from the 5v or 3v pins on your arduino, connected to the ground, and connected to the serial input and output pins on the arduino. The connections are as follows:
Arduino Bluetooth Module
5v pin => VCC
GND => GND
TX => RXD
RX => TXD
The other pins on the modules, if yours has extras, will not be used. Just to be clear, the TX and RX pins on the arduino should not be connected to their counterparts on the bluetooth module, they should be swapped. Another word of warning for when you're testing your code, your arduino cannot be updated with new code while the TX and RX pins are connected to the bluetooth module. You will need to disconnect those pins whenever you need to upload new code to your arduino.
Step 3: Motor Driver
Your motor driver allows you to easily control the two gear motors, as well as manage the power output on them easily. Unfortunately, with everything else connected, there will only be enough pins for the gearmotors themselves, so the power management capabilities will not be available. To connect the motor driver, first solder the headers that come with it to the board for easy connection to a breadboard, then follow this guide on connecting it to your motors, powersupply, and arduino. I soldered mine with the connection labels facing upward when plugged into a breadboard, so I could better tell what I was doing.
PWMA - PWM pin on microcontroller //in our case, we're jumping it to the VCC
AIN2 - digital pin on microcontroller for motor A (negative)
AIN1 - digital pin on microcontroller for motor A (positive)
STBY - digital pin on microcontroller, or tie to VCC
BIN1 - digital pin on microcontroller for motor B (positive)
BIN2 - digital pin on microcontroller for motor B (negative)
PWMB - PWM pin on microcontroller //ditto with PWMA
GND - GND of microcontroller
GND - Microcontroller ground
VCC - VCC from microcontroller (2.7V-5.5V)
AO1 - Output to (-) lead of motor A
AO2 - Output to (+) lead of motor A
BO2 - Output to (+) lead of motor B
BO1 - Output to (-) lead of motor B
VMOT - positive pole of motor battery
GND - negative pole of motor battery
We will be jumping the PWM and STBY connections to the VCC, so the pins connecting the PWMA, PWMB, and STBY should simply jump across to the same row as VCC (which should have a connection to the arduino's 5v or 3v pins)
Step 4: Wave Shield
The wave shield is what gives us the ability to make sounds with our arduino, and stores the files we play on an SD card on the shield itself. Unfortunately, the shield also requires the use of nearly ever PWM pin on the Uno, leaving only pins 6, 7, 8, 9 and the 6 analog in pins available for use. That is just enough to connect our gear motor pins to get us moving. You will need to solder the shield together, following the instructions available on adafruit, as well as download the libraries they have available for it. You will also need to solder male-to-male jumpers to the pins we'll be using for our gearmotors (which are the only available pins left); pins 6, 7, 8, 9 and the TX and RX pins will need jumpers to connect them to the breadboard through the shield, since the fully-assembled wave shield connects directly into the pins on the arduino. Be sure to format your SD card to FAT 32 and make sure your sound files are .wav format. Adafruit has more detailed explanations on the file formats that are allowed.
Step 5: Code and Application
As stated previously, you will need the libraries provided by adafruit in order to operate the wave shield using this code. The code should be fairly self explanatory, it reads in the serial data (that will be sent via bluetooth) and uses a switch case to determine what to do. The application we're using sends 'S' commands if you aren't pressing anything, meaning that the robot will move only while you press a button, and immediately stop upon release.
The phone app I'm using is here. It's pretty simple to use and connect to your bluetooth module. Once connected correctly, the bluetooth module will send out bytes of information through serial, which will be handled by the switch case.
Step 6: All Together
Here you can see my progress building it. The first picture is simply a "proof of concept" progression pic, where I crudely assembled everything and powered her up. it progresses until my current iteration, with the full body and decals. I crafted the "legs" from foam board I had lying around the house.
If there's interest, I'll upload a video of it in action.