ASK AN EDUCATOR! “How can I control an old RC car with an Arduino?”
I’d like to pilot an old RC car with my Arduino.
The motor seems to need something like 600mA @ 9V (thanks to my Amperemeter).
I’d like to know how to do that with a transistor ?
When I make tests, as the base current I put may be too small, my motor don’t move at all.
Same thing when I plug the motor to the battery with a potentiometer, the motor move only if the potentiometer value is less than 2 ohms !
In brief, I’d like to know how to control a motor with an Arduino, the hard way (not with a special shield), and how to calculate the values needed.
Actually the “hard way” is really quite simple, and you only need a few components. Here are two options:
Single direction control (CW only or CCW only):
I would recommend starting with a two TIP120s, one for each motor. The TIP120 is a Darlington transistor which is capable of switching a DC load up to ~5A. Because this is an NPN transistor, you will actually be connecting and disconnecting the negative terminal of your motor, while keeping the positive attached. This makes it easy for the Arduino to turn it on and off (digitalWrite(pin, HIGH) & digitalWrite(pin, LOW). This site gives a good overview, although I would recommend using a base transistor.
You can calculate the proper base resistor by using the following calculation (derived from ermicro):
Vport = 4.2V (the minimum logic HIGH voltage from a 5V powered micro controller)
Vbe = 2.5V
Ic = 1A (desired current)
hFE = 1000
Ib = Ic / hFE = 1 A / 1000 = 0.001 A
Rb = (Vport – Vbe) / Ib = (4.2 – 2.5) / 0.001 = 1700 Ohm, use 1.8k Ohm resistor
P = (Vport – Vbe) x Ib = (4.2 – 2.5) x 0.001 = 0.0017 watt, use 0.25 Watt resistor
Bi-directional control (CW and CCW):
I recommend looking at the L293D. It’s easy to use, not to expensive, and has protection diodes built in. An H-Bridge allows you to digitally reverse the polarity of your motor as well as turn it off.
In both scenarios I would recommend controlling the motors using PWM as you can digitally control their speed.
I did a previous post giving a much more detailed overview of controlling motors using the Arduino if you are need of more info!
Good luck with you RC car, and feel free to ask if you need help controlling it remotely!
Don’t forget, everyone is invited to ask a question!
“Ask an Educator” questions are answered by Adam Kemp, a high school teacher who has been teaching courses in Energy Systems, Systems Engineering, Robotics and Prototyping since 2005.
Adafruit has had paid day off for voting for our team for years, if you need help getting that going for your organization, let us know – we can share how and why we did this as well as the good results. Here are some resources for voting by mail, voting in person, and some NY resources for our NY based teams as well. If there are additional resources to add, please let us know – adafruit.com/vote
Stop breadboarding and soldering – start making immediately! Adafruit’s Circuit Playground is jam-packed with LEDs, sensors, buttons, alligator clip pads and more. Build projects with Circuit Playground in a few minutes with the drag-and-drop MakeCode programming site, learn computer science using the CS Discoveries class on code.org, jump into CircuitPython to learn Python and hardware together, TinyGO, or even use the Arduino IDE. Circuit Playground Express is the newest and best Circuit Playground board, with support for CircuitPython, MakeCode, and Arduino. It has a powerful processor, 10 NeoPixels, mini speaker, InfraRed receive and transmit, two buttons, a switch, 14 alligator clip pads, and lots of sensors: capacitive touch, IR proximity, temperature, light, motion and sound. A whole wide world of electronics and coding is waiting for you, and it fits in the palm of your hand.
Get the only spam-free daily newsletter about wearables, running a "maker business", electronic tips and more! Subscribe at AdafruitDaily.com !
Another way to control an RC car’s motor is to use the same device most RC cars use. It’s called an ESC for Electronic Speed Control and it’s controlled the same way an RC servo is controlled. That is, you send it a repeating pulse train and vary the width of the pulse to control the speed of the motor. So, this means you can use the Arduino’s Servo library to control it. Just be aware that there are some nuances such as the fact that most ESCs can control a motor in both forward and reverse and also can have a braking feature. The typical approach is that a neutral position pulse (servo centered) is OFF and that a longer and shorter pulse widths engage forward and reverse.
I couldn’t agree more. I assembled a couple of those kits back in their Halcyon days (late 80s early 90s.)
Keep in mind there were two ways an RC motor could be controlled. The old way was via servo, where the servo would rotate an "arm" onto the appropriate metal pad completing a circuit that would drive the motor forward at 1/3, 2/3, full, or reverse speed. These were replaced with electronic speed controls which for the purposes of maintaining backward compatibility with the radio receivers accepted the servo input signals directly. So basically you can reverse engineer the PWM by plugging it into a square wave generator.
The best part about controlling an RC car via PWM into a "servo" ESC is that you can use the exact same trick to control the STEERING which is likewise controlled via a servo.
Finally I found an image of the classic servo speed controller: