Robot 2WD Ultrasonic Servo Controlled Kit

Out Of Stock



The Motor Robot Car Kit 2WD is an ideal choice for those looking to build a simple and functional robot car. This kit includes several components that allow you to create a two-wheeled robot capable of measuring distances using an HC-SC04 Ultrasonic module. 


Package Includes:

  • 1x Arduino UNO R3 ATmega328 (compatible): The brains of your robot, an Arduino microcontroller for programming and control.
  • 1x Robot 2 Wheel Drive Smart Car Chassis Kit: The mechanical structure of the car, providing support and mobility.
  • 1x Motor Driver Module (L298N): This module helps control the motors on the car, allowing it to move in different directions.
  • 1x Ultrasonic HC-SR04 Module Distance Sensor: A critical component for distance measurement.
  • 1x Servo Motor Micro TowerPro SG90 9G: This servo motor is used to mount the Ultrasonic sensor, enabling it to scan multiple angles.
  • 1x Servo Nylon Holder: Used to securely mount the Ultrasonic sensor.
  • 1x Expansion V5.0 Sensor board Shield for UNO: An expansion shield for connecting and controlling various sensors.



  1. Arduino UNO R3 ATmega328 (compatible): This kit features an Arduino UNO R3 microcontroller, which serves as the brains of your robot. It's not only compatible with Arduino programming but also offers an ATmega328 microcontroller at its core. This provides a versatile platform for developing and controlling your robotic project, allowing you to program it to perform a wide range of tasks.
  2. Robot 2-Wheel Drive Smart Car Chassis Kit: The mechanical structure of the kit is provided by a 2-Wheel Drive Smart Car Chassis. This chassis is designed to offer robust support and mobility, making it an ideal choice for your robot's foundation. It provides the stability needed for smooth movements, and its two-wheel drive system ensures efficient locomotion.
  3. Motor Driver Module (L298N): For precise control of the robot's motors, this kit includes an L298N Motor Driver Module. This module is essential for managing the direction and speed of the motors, enabling your robot to move in different directions and even execute complex maneuvers with ease.
  4. Ultrasonic HC-SR04 Module Distance Sensor: Distance measurement and obstacle detection are critical aspects of robotics. The kit includes an Ultrasonic HC-SR04 Module, which is an ultrasonic sensor designed to accurately measure distances. This sensor is indispensable for helping your robot navigate and avoid obstacles in its environment.
  5. 1x Servo Motor Micro TowerPro SG90 9G: Enhancing the capabilities of your robot, this kit includes a versatile Servo Motor, specifically the TowerPro SG90 9G. This servo motor is used to mount the Ultrasonic sensor, enabling it to scan multiple angles and accurately detect objects in its path. It provides the necessary motion and precision for effective sensor orientation.
  6. Servo Nylon Holder: To ensure stability and accuracy in sensor positioning, the kit provides a Servo Nylon Holder. This component securely mounts the Ultrasonic sensor, preventing unwanted movement or vibrations, which can lead to inaccurate readings. A stable sensor position is crucial for reliable distance measurements and obstacle detection.
  7. Expansion V5.0 Sensor Board Shield for UNO: To expand the sensor capabilities of your Arduino UNO R3, this kit includes an Expansion V5.0 Sensor Board Shield. This shield allows for the connection and control of various sensors, enhancing the functionality of your robot. It opens up opportunities to add more sensors and modules, such as temperature sensors, IR sensors, or even cameras, depending on your project's requirements.



At its core, this kit features an Arduino UNO R3 microcontroller, which is not only compatible with Arduino programming but also houses the powerful ATmega328 microcontroller. This combination provides you with an exceptional platform for programming and controlling your robot, allowing you to bring your creative ideas to life. The mechanical structure is provided by the 2 2-wheel drive Smart Car Chassis Kit, offering both stability and mobility. Its two-wheel drive system ensures efficient locomotion, enabling your robot to traverse different surfaces and terrains. Precise motor control is achieved through the inclusion of the L298N Motor Driver Module. This module empowers your robot to move in multiple directions and execute intricate maneuvers, from straightforward movements to precise turns. For accurate distance measurement and obstacle detection, the kit incorporates the Ultrasonic HC-SR04 Module. This sensor is a cornerstone for autonomous navigation and environmental interaction, providing your robot with the ability to sense and adapt to its surroundings. With the Comprehensive Robotics Kit, you have the foundation to explore the limitless possibilities of robotics. Whether your interests lie in educational experimentation, innovative projects, or practical applications, this kit is your gateway to a world of robotics and automation.


Principle of Work and how to assemble:

This is an easy-to-read guide for assembling your robot you can find a more detailed assembly tutorial in the resources:

1. Mount the Swivel Wheel

  • Parts Needed: Swivel Wheel, 4 × 5 mm M3 screws, 4 × M3 nuts
  • Determine the top of the baseplate using the Arduino as a guide.
  • Attach the swivel wheel to the bottom of the baseplate using the screws and nuts.

2. Mount the Arduino and Sensor Shield

  • Parts Needed: Arduino, Sensor Shield, 2 × 10 mm M3 spacers, 4 × 5 mm M3 screws
  • Connect the two spacers to the top of the baseplate using two screws.
  • Mount the Arduino on the spacers using the other two screws.
  • Mount the Sensor Shield atop the Arduino, ensuring that the right edges of the boards align, and ensure that each pin goes into a connector.

3. Mount the Motors on the Bottom of the Baseplate

  • Parts Needed: 2 × motors, 2 × 10 cm wires (black), 2 × 10 cm wires (red), 4 × acrylic tabs, 4 × 30 mm M3 screws, 4 × M3 nuts, 2 × Wheels
  • Solder one red and one black wire to each motor, with either terminal for either color.
  • Place one tab into a slot down from the top of the baseplate, align the motor, and place the other tab on the slot on the side of the baseplate.
  • Insert two screws from the outside tab through the motor and inside tab, and connect the nuts.
  • Repeat the procedure for the other motor.
  • Mount the wheels on the motors.
  • (Optional) Attach the optical interruptor discs on the inside axles.

4. Mount the Switch, the Battery Holder, and L298N

  • Parts Needed: Rocker switch, L298N board, Battery holder, 3 × 5 mm M3 screws, 2 × 8 mm countersunk M3 screws, 2 × 10 mm M3 spacers, 1 × M3 nut
  • Insert the switch on the top of the baseplate between the two motors.
  • Locate the battery holder on the underside of the baseplate just in front of the swivel and insert the two countersunk M3 screws into the leftmost and rightmost holes.
  • Connect one of the screws to the M3 nut, and the other to a spacer.
  • Connect the other spacer to the baseplate with a 5 mm M3 screw.
  • Remove the three jumpers on the L298N board by pulling them up.
  • Mount the L298N board to the two protruding spacers with the other 5 mm screws.

5. Download the Firmware to Center the Servo

  • Parts Needed: Computer, Servo Motor, "robot-car.ino" sketch, USB cable
  • Download and install the Arduino IDE.
  • Start the Arduino IDE.
  • Open the "robot-car.ino" sketch.
  • Make sure the correct board (Arduino Uno) is selected.
  • Plug the servo motor connector into the column of pins labeled "11" on the Sensor Shield.
  • Connect the USB cable between your computer and the Arduino.
  • Make sure a port is selected.
  • Click "upload" to send the sketch to the Arduino.
  • Disconnect the USB cable once the servo centers.

6. Assemble the Ultrasonic Sensor Mount

  • Parts Needed: Ultrasonic sensor base, Ultrasonic sensor sides, 2 × 3 mm self-tapping screws, 2 × 7 mm self-tapping screws, Servo motor, 1 × 8 mm pan-head screw, White two-arm servo connector
  • Trim the two arms of the servo connector to fit the base.
  • Attach the servo arm to the base with the 3 mm self-tapping screws.
  • Attach the servo to the base using the 8 mm pan-head screw.
  • Connect the two halves of the mount with the 7 mm screws to clamp the servo.
  • Strap the ultrasonic sensor, pins up, to the mount with twist ties.

7. Attach the Ultrasonic Sensor to the Baseplate

  • Parts Needed: 4 × 11 mm M1 screws, 4 × M1 nuts
  • Attach the base of the ultrasonic sensor to the top of the baseplate with the screws and nuts.

8. Connect the Power and Motor Wires

  • Parts Needed: 1 × 20 cm red wire, 1 × 12 cm red wire, 1 × 12 cm black wire
  • Solder the red wire from the battery holder to one switch terminal.
  • Solder the 20 cm red wire to the other switch terminal.
  • Connect the two left motor wires to the left connector on the L298N and the two right motor wires to the right connector.
  • Connect two 12 cm lengths of wire to the black (ground) wire from the battery holder and the red (power) wire from the power switch.
  • Connect the doubled black (ground) wire to the "GND" terminal on the shield.
  • Connect the doubled red (power) wire to the "VCC" terminal on the shield.
  • Connect the black 12 cm wire from the shield terminal to the middle screw terminal on the L298N.
  • Connect the red 12 cm wire from the shield terminal to the left screw terminal on the L298N.

9. Connect the Ultrasonic Sensor, Servo, and L298N to the Arduino Sensor Shield

  • Parts Needed: 4 × 20 cm female-to-female jumper wires, 7 × 10 cm female-to-female jumper wires
  • (Details provided in the original instructions)


  1. Check Power Supply:

    • Lift the robot off the ground and connect the USB cable between the Arduino and your computer.
    • Ensure that power lights are illuminated on the Arduino, Sensor Shield, and L298N motor controller.
    • If any of these lights are not lit, carefully inspect the power wiring for any issues.
  2. Servo Centering:

    • Shortly after powering on or resetting the robot, it should automatically center the servo.
    • If the servo does not move, first confirm that you have connected the servo to location 11, and the orange wire is properly connected to "S."
    • If the servo moves but doesn't center correctly, remove the ultrasonic sensor mount from the board, disconnect the servo from the base, and reattach the servo in the correct location.
  3. Wheel Movement:

    • After centering the servo, the robot should perform test movements: left wheel forward and backward, followed by the right wheel forward and backward.
    • If one of the wheels turns backward, swap the red and black motor wires on the L298N board to reverse its direction.
    • If only one wheel turns while the other does not, carefully inspect the motor wiring and the connections between the Arduino and the L298N board.
  4. Battery Operation:

    • Disconnect the robot from the computer, turn off the power switch, and insert 4 AA batteries into the holder on the bottom of the robot.
    • Turn on the power switch, and once again, ensure that power lights illuminate on all components.







No library is needed for the module to work.



The code controls the robot's movements based on the information obtained from the ultrasonic sensor, allowing it to navigate while avoiding obstacles:

#include "Servo.h"

Servo servo;
// Ultrasonic Module pins
const int trigPin = 13; // 10 microsecond high pulse causes chirp, wait 50 us
const int echoPin = 12; // Width of high pulse indicates distance
// Servo motor that aims the ultrasonic sensor.
const int servoPin = 11; // PWM output for the hobby servo
// Motor control pins: L298N H bridge
const int enAPin = 6; // Left motor PWM speed control
const int in1Pin = 7; // Left motor Direction 1
const int in2Pin = 5; // Left motor Direction 2
const int in3Pin = 4; // Right motor Direction 1
const int in4Pin = 2; // Right motor Direction 2
const int enBPin = 3; // Right motor PWM speed control
enum Motor { LEFT, RIGHT };
// Set motor speed: 255 full ahead, -255 full reverse, 0 stop
void go(enum Motor m, int speed) {
  digitalWrite(m == LEFT ? in1Pin : in3Pin, speed > 0 ? HIGH : LOW);
  digitalWrite(m == LEFT ? in2Pin : in4Pin, speed <= 0 ? HIGH : LOW);
  analogWrite(m == LEFT ? enAPin : enBPin, speed < 0 ? -speed : speed);

// Initial motor test:
// left motor forward then back
// right motor forward then back
void testMotors() {
  static int speed[8] = {128, 255, 128, 0, -128, -255, -128, 0};
  go(RIGHT, 0);
  for (unsigned char i = 0; i < 8; i++)
    go(LEFT, speed[i]), delay(200);
  for (unsigned char i = 0; i < 8; i++)
    go(RIGHT, speed[i]), delay(200);

// Read distance from the ultrasonic sensor, return distance in mm
unsigned int readDistance() {
  digitalWrite(trigPin, HIGH);
  digitalWrite(trigPin, LOW);
  unsigned long period = pulseIn(echoPin, HIGH);
  return period * 343 / 2000;

#define NUM_ANGLES 7
unsigned char sensorAngle[NUM_ANGLES] = {60, 70, 80, 90, 100, 110, 120};
unsigned int distance[NUM_ANGLES];

// Scan the area ahead by sweeping the ultrasonic sensor left and right
// and recording the observed distance. This takes a reading, then
// sends the servo to the next angle. Call repeatedly once every 50 ms or so.
void readNextDistance() {
  static unsigned char angleIndex = 0;
  static signed char step = 1;
  distance[angleIndex] = readDistance();
  angleIndex += step;
  if (angleIndex == NUM_ANGLES - 1) step = -1;
  else if (angleIndex == 0) step = 1;

// Initial configuration
void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  digitalWrite(trigPin, LOW);
  pinMode(enAPin, OUTPUT);
  pinMode(in1Pin, OUTPUT);
  pinMode(in2Pin, OUTPUT);
  pinMode(in3Pin, OUTPUT);
  pinMode(in4Pin, OUTPUT);
  pinMode(enBPin, OUTPUT);
  go(LEFT, 0);
  go(RIGHT, 0);
  for (unsigned char i = 0; i < NUM_ANGLES; i++)
    readNextDistance(), delay(200);

// Main loop:
void loop() {
  unsigned char tooClose = 0;
  for (unsigned char i = 0; i < NUM_ANGLES; i++)
    if (distance[i] < 300)
      tooClose = 1;
  if (tooClose) {
    go(LEFT, -180);
    go(RIGHT, -80);
  } else {
    go(LEFT, 255);
    go(RIGHT, 255);


  1. It includes the Servo library and defines the necessary variables for pins connected to various components:

    • trigPin and echoPin for the ultrasonic sensor
    • servoPin for the servo motor
    • Pins for controlling the motors using an L298N motor driver (enAPin, in1Pin, in2Pin, in3Pin, in4Pin, enBPin)
    • An enum Motor to distinguish between the left and right motors
  2. It defines a function go() to control the motors. It sets the direction and speed of the motors based on the specified Motor and speed parameters.

  3. It defines a function testMotors() to test the motors. It alternates between different motor speeds for both left and right motors.

  4. It defines a function readDistance() to read the distance from the ultrasonic sensor and returns it in millimeters. It uses the pulseIn function to measure the time taken for the ultrasonic pulse to bounce back.

  5. It defines an array sensorAngle to specify the angles at which the ultrasonic sensor should be positioned during scanning.

  6. It defines an array distance to store the distance measurements corresponding to different sensor angles.

  7. It defines a function readNextDistance() to sweep the ultrasonic sensor left and right and record the distances observed. It changes the sensor angle and updates the distance data as the sensor scans the area.

  8. In the setup() function, it initializes the pins and performs the following tasks:

    • Sets up pins for the ultrasonic sensor, motor control, and servo.
    • Initializes the servo motor and sets it to the initial position.
    • Calls testMotors() to perform an initial motor test.
    • Initiates the first ultrasonic sensor scan by calling readNextDistance() and delaying for 200 milliseconds.
  9. In the loop() function, it continuously loops through the following tasks:

    • Calls readNextDistance() to update distance measurements.
    • Checks if any obstacle is detected by examining the distance array.
    • If an obstacle is too close (less than 300mm), it instructs the robot to back up and turn.
    • If there are no obstacles, the robot is instructed to move forward.