Steering control mechanism for RC car using Servo motor and Arduino

A servo steering mechanism is a simple method that can be used to precisely control the steering position of RC cars and small robots. Unlike normal DC motor-based steering a servo control is by means angular degree so the motor itself can stop and maintain a position without additional mechanical parts or stopper.

servo steering mechanism arduino rc robot tyre

Refer

Code

#include <Servo.h>

Servo servo_steering;

const int switch_left = 2, switch_right = 3;
int left_degree = 45, center_degree = 90, right_degree = 135;

void setup() {
  servo_steering.attach(9);
  pinMode(switch_left, OUTPUT);
  pinMode(switch_right, OUTPUT);
}

void loop() {
  while (digitalRead(switch_left) == HIGH) {
    servo_steering.write(left_degree);
    delay(15);
  }
  while (digitalRead(switch_right) == HIGH) {
    servo_steering.write(right_degree);
    delay(15);
  }
  servo_steering.write(center_degree);
  delay(15);
}

In the above code, the servo arms rest at a 90° position; it is the centre position of a 180° servo. Here the servo arm moves left and right when the corresponding switches are pressed, it maintains the position as long as the switch is pressed. Once released the arms return to the rest position.

The angle value for the left is given as 45° and the right is 135° degree; that is 45° degrees clockwise and anticlockwise from the centre position 90°. By changing these values, the required range of motion can be adjusted or fine-tuned. Here the left or right range of motion or centre resting positions can be independently adjusted to any degrees. So in this method calibrating the tyre position is quite simple and reliable compared to mechanical arrangements with ordinary motors.

For a remoter controlled operation, the condition function can be replaced in the receiver the side code with wireless data or msg to run the servo write code or call it as a function given below.

Refer RF remote controlled robot using Arduino and 433mhz ASK module.

void left() {
   servo_steering.write(left_degree);
   delay(15);
}
void right() {
   servo_steering.write(right_degree);
   delay(15);
}

Leave a Reply

Your email address will not be published. Required fields are marked *