Question:RC Car steering using a dc motor and pot?


My stepfather asked me to try to fix an old RC car he was given. The existing board in the car has a few fried components that I can’t identify so I can’t just replace them.

Therefore, I thought I could use this as a good learning experience. I have already sorted out the RC part. I’m using Sparkfun’s 433 MHz RX/TX modules and the VirtualWire library together with a Wii nunchuck. That part works a treat together with the receiving code I threw together.

My problem concerns how to steer the thing! I opened up the vehicle and found the steering is controlled by a dc motor which is connected to a pot via some gears and through that to the steering linkages (I think that’s the correct term). I’ve already established that I can read the pot separately via an analog pin and I’m currently using a SN754410 chip to control the speed and direction of the motor (ignoring the pot for now).

Can someone point to me to some sample code that could help get me started ? I figured I’d need to read the pot first, somehow convert that (possibly using map) to a value that can match the steering command I receive via the remote and see if I need to move the motor, and, if so, how fast should the motor move, i.e. was it an abrupt change, like yanking the steering, or a gentle turn (I’ll already know the direction from the TX). Commands from the TX will be in the format R0 (steer straight), R12 (steer Right 12), L45 (steer left 45). I figured I’d try to use the numbers as degrees to turn.

Any help, pointers or just ‘Hey that won’t work because …’ gratefully accepted :slight_smile:


Hey that will work because you seem to have a good idea on how to solve the problem.

Actually, based on what you’ve told me, it seems spot on.

recieve and interpret command
read pot

Hmm, I guess what I wasn’t sure about was how to keep reading the pot until its output matches how far I’ve told the steering to turn and stop it when it arrives at that point. Since I have to connect the pot to an analog pin I can’t use an interrupt, correct ? In which case I’ll have to modify my void loop() to use some sort of state machine.

I’ve disconnected the motor from the steering linkages while I’m testing so I don’t stall the motor or strip the gears.

Thanks for verifying my analysis was correct :slight_smile:


You may be interrested in having a look at my FiniteStateMachine Library, still in beta though.

As for how to continously check:

const char minAngle = -60;
const char maxAngle = 60;

//angle in degrees
turnWheelToAngle( int targetAngle  ){
   unsigned int potentiometerPosition = analogRead( potPin ); 
   int currentAngle = map( potentiometerPosition , 0 , 1024 , minAngle , maxAngle );
   while ( currentAngle != targetAngle ){
     currentAngle < tergetAngle ? currentAngle++ : currentAngle--;
     setWheelToAngle( currentAngle ); //TODO - create and provide functionality

Thanks, I’ll test it tomorrow as it’s getting late :frowning:

I’ve used the same exact RF modules for my dual-nunchuck controlled robotic arm.

*What are you controlling the steering with? (a microcontroller?)

-To me it sounds like you are trying to completely bypass the original onboard controller. If you would like me to try and spec out what you could salvage out of your car’s board take a good pic and post it.

From what I understand, you should read the resistance of the pot at its maximum left, and maximum right.
steer_range = absolute_value[max_right - max_left]
= max_pot_reading - min_pot_reading

steer_center = max_pot_reading - steer_range/2
OR = the reading you receive when wheels are straight.

Send a byte to the receiver for steering. 1 byte has 256 possible steering positions(0-255). Which seems a bit much, but if you do it this way:
(0x denotes hexadecimal. 0x00 = 0, 0x05 = 5, 0xB4 = 180)

sending 0x00 could be max_left, and 0xFF(255) your max_right.
When your steering controller receives the byte, all it has to do is compare it to the current pot reading, then move it toward that value until its close enough. This is like the “mapping” you mentioned.
to convert from the byte:

scale_factor = steer_range/byte_range = steer_range/256

steer_to_position = received_steer_byte*scale_factor + min_pot_reading

This is the idea, but it is late so I might just be rambling, hope I’m not making this more confusing :0)

by the way, if you are not using an antenna with these RF modules, you don’t get great distance. I had to use 1200 bps just to get reliable signals. People have suggested using a long wire (few inches)


Woops…I havn’t used those RF modules. I used the 433 KHz, not MHz

I had to bypass the car’s original gubbins because some of it’s components were fried. I can’t tell what they were, they’ve been reduced to blobs.

That’s exactly the approach I’m trying to take. Haven’t had much time to dedicate to this though.

I was planning on using the wire aerial that came with the car originally.

Thanks !