Introduction: Add Sound Effects to Your R/C Car
R/C Animator is based on the Propeller Platform USB — effects can include changing the position of a secondary servo, playing back CD quality audio, or changing lights. On my R/C car, I'm using four LED's and a mono speaker for audio playback. Continue to the next step and I'll show you how to make it!
Step 1: FAQ
How does it work?
R/C Animator triggers effects based on the position of the servos in your vehicle. So, you can trigger the playback of a rumbling V8 when the throttle servo opens up. Or you could connect a spare servo channel to the R/C Animator to turn on an LED 'light bar' and play a siren.
I'll show you how to customize the logic for whatever effects you want, too.
What effects are available?
Up to 32GB of audio samples can be stored and played back in CD quality stereo. An onboard audio amp will drive speakers up to 1/4 Watt.
Up to 25 LED's can be turned on, blinked, or faded.
Secondary servo movements
Multiple servos can be directly controlled by R/C Animator, so a single wireless channel can trigger secondary servo animations
R/C Animator is designed to chain and combine these effects.
Will it work with my vehicle?
Most likely. Digital and analog servos use the same signalling method. If you're using old airtronics servos (non-z connector), you'll need to flip a wire.
How many batteries does it take?
None — It runs off the servo power and only draws a few mA.
What are the dimensions?
7.2cm x 6.3cm x 2.54cm (2.8" x 2.5" x 1.0"). The basic R/C Animator weighs about 40g (1.5oz). If you use audio, you'll also need to include the weight of the speaker.
Step 2: Preparation: Parts and Tools
PartsFor the base R/C animator, you'll need a few parts;
- Propeller Platform USB (Gadget Gangster, Adafruit)
- ProtoPlus board (Gadget Gangster, Adafruit)
- Connectors: 46 headers, 7 sockets, and a spare servo header
- Parts: 4.7k resistor, and LED's
ToolsAssembly takes about an hour, including setting up the lights. If you've never soldered before, there are a bunch of great instructables to guide you, like this one. You'll need a few tools:
- Soldering Iron and solder. Leaded solder is easier to work with, and a 15-40 watt iron is just fine.
- Dikes. Diagonal cutters are used to trim the excess leads from components after soldering them down. I use a pair I got from Ikea for two bucks.
Step 3: Wires
- Three wires in the middle will connect both sets of servo headers
- Two wires connecting P12 and P13 pull power from the R/C receiver to power the Propeller Platform USB
- One jumper from the base of R1 to the top of C2 connects Ground
- One jumper from the base of R2 to V50 connects power
We draw a little power (through Vcc) to run the R/C Animator and the rest goes on to the servo. We spy on the servo status through a 4.7k ohm resistor connected to the servo signal wire.
Step 4: Connectors
There are a few options here — An easy one is to take an old or broken servo and use your dikes to cut off the header and the wire. If you do that, don't connect the right angle header — Instead, connect the wires here;
The black wire goes where the black circle is. Same with the red and orange. Now, add the resistor as shown . It connects the signal line to the Propeller Platform.
Add the pin socket from P7 - P13, as shown below. Our lighting LED's will be added to the R/C vehicle shell, so these sockets allow us to easily disconnect the R/C animator from the shell.
Finally, add pin headers pointing down, as shown in the photo.
- A strip connecting P4..P12
- Two headers connecting P14..P15
- Connect P16..P32
- And don't forget to connect Vin, V50, V33, and GND on both sides of the board.
Step 5: Body Work
- Two act as brake lights
- Two act as headlights
I wanted the headlights to take a crisp, rectangular shape when turned on. An easy way to do this is to use masking tape to block off the parts of the shell that shouldn't get illuminated, as I've done in the photo. Chipboard works well, too.
Step 6: Body Wiring
The mnemonic I use is that getting 'less lead' is a negative thing, hence it's the cathode. Getting more lead is a positive thing, so it's the anode. All of the LED's on the body will have their cathodes (short leads) connected together, in a chain. At the end of the chain, add a foot or so of hookup wire, this will eventually connect back to the R/C Animator;
The LED's don't share anodes, though. Connect hookup wire to each anode separately. Start at the end of the chain, twisting the wires together as you add each LED;
If you're connecting four LED's you'll have five wires;
- one wire that's connected to the long lead (cathode) of all the LED's.
- four wires that each connect to the short lead (anode) of a single LED.
It doesn't matter what position the other wires are in, you can even skip a pin if you'd like. But make sure the shared cathode wire is on the rightmost position. This is a pretty weak connector, I suggest re-enforcing it with some hot glue.
Here's the circuit, too;
Step 7: Testing
The final step of the build is to connect the R/C Animator to the Servo, radio receiver, and the lights installed on the vehicle.
Loosely connect the R/C animator to your vehicle and test it by turning on the receiver and transmitter. Everything should work the same as before the R/C Animator was connected. If you're having a problem here, first check the batteries on your vehicle and transmitter. Then check to make sure the servo connections are correct.
Once the test is passed, mount the R/C Animator securely in the chassis. Zip ties are handy for this.
Software SetupInstall the Propeller Tool on your computer (Mac, Linux, Windows Instructions). First, let's figure out which LED is connected to which pin. Open up The Propeller Tool and enter the following program;
Turn on your R/C transmitter and the receiver on the vehicle, and hit F10. The first LED that lights up is connected to P7, the second is connected to P8, and so on. Write it down. Here's what my setup looks like;
If one of your LED's doesn't light up, check the wiring for that LED. Make sure the cathode is connected to all the other LED's and make sure the Anode is connected to the R/C Animator. If none of the LED's light up, check the cathode wire to make sure they're all connected.
Step 8: Customization
R/C Animator is meant to be customized! Start by downloading the code, and unzip it into a new directory on your desktop. Open up Animator_Demo.spin. This is the same code that's running on the demo video earlier.
The CodeThe demo is a good starting point for making your own custom effects, so I'll break it down, starting at the beginning;
First, we have the CON block. The first two lines set the clock speed of the Propeller Platform. You won't ever need to change these. The next line is what pin the servo is connected to. The next four lines are the pins each LED is connected to.
After that, there's an OBJ block. This includes the RC_Animator_010.spin object, which was included in the zip file and is where most of the heavy lifting occurs.
Everything is set up, here's the program;
This starts monitoring the pin connected to the servo. Once monitoring has started,
animate.servopositionwill return the current position of the servo.
IF animate.servoposition > animate#servomax
animate.servoposition returns the position of the servo. If it's at the maximum position, the code under this if statement will run.
fade the left headlamp for 500 milliseconds. The third argument selects whether we want it to fade down, or fade up.
animate.fade(llamp,500,1)will fade the lights up, but we could use
animate.fade(llamp,500,2)to fade the light down. The next line,
animate.fade(rlamp,500,1)does the same thing, but for the right headlamp.
Pause things for 3,000 milliseconds, or three seconds.
animate.wait(5000)would pause for five seconds, and
animate.wait(500)would pause for a half second.
In addition to fading a light, we can simply turn it on with this command. A light can be turned off with
animate.ledoff(llamp), as well.
Playback an audio file stored on the microSD card with the filename duke.wav. Files must be 16-bit stereo wavs, and stored on the root directory of the microSD card (no subdirectories).
Play a wave file stored on the microSD card with the filename given. Note that R/C Animator doesn't support directories, everything has to be on the root of the card. But SDHC (cards greater than 2GB) are supported.
turn the LED connected to pinnum on
turn the LED connecto to pinnum off
Hold up for the number of milliseconds given. There are 1,000 milliseconds in a second. This is helpful for creating realistic complex animations - like pausing before blinking a light or playing an audio file
Fade an LED connected to pinnum. The duration of the fade will be milliseconds. If you set selector to 1, you'll get a fade up, if selector is 2, the light will start full and fade down.
This is for controlling a secondary servo. Before you can do this, be sure to first call servoSlaveStart, once in the program. The max position is 2,500 and the minimum position is 500.
Step 9: Adding Audio
- Small Speaker
- LM368 Audio Amp
- 220uF Electrolytic capacitor
- 10k ohm potentiometer
- Screw Terminal connector
- microSD card to hold samples
Start by adding a few jumpers;
there will be seven jumpers, total, and I've marked them with a black line in the photo.
Add the audio amp (the LM386). Note the position of the notch on the chip in relation to the board;
Now, add the volume knob;
The middle pin on the knob connects to P4 on the Propeller Platform. One leg connects to the third pin on the amp, and the other pin connects to ground.
Now, add the big capacitor;
Note the stripe on the Capacitor. It indicates the negative side, and it should go as shown in the photo.
Finally, add the Audio connector;
Speakers have two leads, one lead goes in each screw terminal connector. They aren't polarized, so it doesn't matter which lead goes to which terminal.
Step 10: Next Steps
I hope you enjoyed putting together the R/C Animator! The first thing to do is to customize it for your particular animation needs, and that's covered in step 8.
We're triggering effects based on servo positions, but we could also trigger effects with other sensors. Maybe a photoresistor would trigger the lights to go on automatically when it's dark. Or an accelerometer could trigger a secondary servo when acceleration is sensed.
You can define triggers like 'Move throttle to max, back to min, and back to max within 2 seconds' to get the most out of limited servo channels.