Stufin
Home Quick Cart Profile

2WD Two Wheel Drive DIY Kit - A Smart Robot Car with Chassis

Buy Now on Stufin

Chassis Dimensions

180 x 120 x 50 mm

Motor Type

2 x DC Gear Motors

Motor Speed

Up to 150 RPM

Power Supply

7.4V, 1200mAh Li-ion Battery

Microcontroller Compatibility

Arduino, Raspberry Pi, ESP32

Sensor Mounting Options

Ultrasonic, Infrared, Line-Tracking Sensors

I/O PortsUSB, UART, GPIO

Weight

Approximately 350g

Documentation and Resources

The kit comes with a comprehensive user manual, including detailed assembly instructions, wiring diagrams, and programming guides. Additionally, users can access online resources, such as tutorials, code examples, and community forums, to help them get started with their projects.

Pin Configuration

  • 2WD Two Wheel Drive DIY Kit - A Smart Robot Car with Chassis
  • Pinout Description
  • The 2WD Two Wheel Drive DIY Kit comes with a pre-assembled chassis and motor drivers, making it easy to build a smart robot car. The kit includes a motor driver board with a set of pins that need to be connected to control the robot's movement and other functions. Below is a detailed description of each pin and how to connect them:
  • Motor Driver Board Pins:
  • 1. VIN (5V-12V)
  • Description: Power input pin for the motor driver board.
  • Connection: Connect to a suitable power source (5V-12V DC) using a power cable or battery.
  • 2. GND
  • Description: Ground pin for the motor driver board.
  • Connection: Connect to the negative terminal of the power source or the ground wire of the battery.
  • 3. ENA (Left Motor Enable)
  • Description: Enable pin for the left motor.
  • Connection: Connect to a digital output pin on a microcontroller (e.g., Arduino) to control the left motor.
  • 4. IN1 (Left Motor Forward)
  • Description: Input pin to control the direction of the left motor (forward).
  • Connection: Connect to a digital output pin on a microcontroller to control the left motor's direction.
  • 5. IN2 (Left Motor Backward)
  • Description: Input pin to control the direction of the left motor (backward).
  • Connection: Connect to a digital output pin on a microcontroller to control the left motor's direction.
  • 6. ENA (Right Motor Enable)
  • Description: Enable pin for the right motor.
  • Connection: Connect to a digital output pin on a microcontroller to control the right motor.
  • 7. IN3 (Right Motor Forward)
  • Description: Input pin to control the direction of the right motor (forward).
  • Connection: Connect to a digital output pin on a microcontroller to control the right motor's direction.
  • 8. IN4 (Right Motor Backward)
  • Description: Input pin to control the direction of the right motor (backward).
  • Connection: Connect to a digital output pin on a microcontroller to control the right motor's direction.
  • 9. VCC (5V Output)
  • Description: 5V output pin from the motor driver board's voltage regulator.
  • Connection: Can be used to power other components on the robot, such as sensors or a microcontroller.
  • 10. 5V (Motor Driver Board Voltage Regulator Output)
  • Description: 5V output pin from the motor driver board's voltage regulator.
  • Connection: Not used in most cases, but can be used as an alternative 5V power source.
  • Additional Connections:
  • Motor Connections:
  • + Connect the left motor wires to the motor driver board's M1A and M1B pins.
  • + Connect the right motor wires to the motor driver board's M2A and M2B pins.
  • Microcontroller Connections:
  • + Connect the microcontroller's ground wire to the GND pin on the motor driver board.
  • + Connect the microcontroller's digital output pins to the corresponding ENA, IN1, IN2, ENB, IN3, and IN4 pins on the motor driver board.
  • Important Notes:
  • Make sure to connect the power source and motors correctly to avoid damage to the motor driver board or other components.
  • Use a suitable power source and motor combinations to ensure the motor driver board can handle the current requirements.
  • Consult the motor driver board's datasheet and the microcontroller's documentation for specific connection and programming guidelines.
  • By following these pinout descriptions and connection guides, you can successfully assemble and control your 2WD Two Wheel Drive DIY Kit smart robot car.

Code Examples

2WD Two Wheel Drive DIY Kit - A Smart Robot Car with Chassis
Overview
The 2WD Two Wheel Drive DIY Kit is a smart robot car with a chassis, designed for hobbyists and enthusiasts to build and program their own autonomous vehicles. The kit includes a robust chassis, two DC motors, an Arduino-compatible microcontroller board, and various sensors for navigation and control.
Technical Specifications
Microcontroller Board: Arduino-compatible, ATmega328P processor
 Motor Control: L298N H-bridge motor driver
 Sensors: Ultrasonic sensor, Infrared sensor, and Line tracking sensor
 Chassis: Aluminum alloy, durable and lightweight
 Power Supply: 6V-12V DC power supply
Getting Started
Before diving into code examples, ensure you have the following components connected correctly:
1. Connect the microcontroller board to the motor driver (L298N) and sensors (ultrasonic, infrared, and line tracking).
2. Connect the DC motors to the motor driver.
3. Power the system using a 6V-12V DC power supply.
Code Examples
### Example 1: Basic Motor Control
This example demonstrates how to control the robot car's movement using the microcontroller board.
```c
const int leftMotorForward = 2;  // Pin for left motor forward movement
const int leftMotorBackward = 3; // Pin for left motor backward movement
const int rightMotorForward = 4;  // Pin for right motor forward movement
const int rightMotorBackward = 5; // Pin for right motor backward movement
void setup() {
  pinMode(leftMotorForward, OUTPUT);
  pinMode(leftMotorBackward, OUTPUT);
  pinMode(rightMotorForward, OUTPUT);
  pinMode(rightMotorBackward, OUTPUT);
}
void loop() {
  // Move forward
  digitalWrite(leftMotorForward, HIGH);
  digitalWrite(rightMotorForward, HIGH);
  delay(1000);
// Move backward
  digitalWrite(leftMotorBackward, HIGH);
  digitalWrite(rightMotorBackward, HIGH);
  delay(1000);
// Stop
  digitalWrite(leftMotorForward, LOW);
  digitalWrite(rightMotorForward, LOW);
  digitalWrite(leftMotorBackward, LOW);
  digitalWrite(rightMotorBackward, LOW);
  delay(1000);
}
```
### Example 2: Obstacle Avoidance using Ultrasonic Sensor
This example demonstrates how to use the ultrasonic sensor to detect obstacles and adjust the robot car's movement accordingly.
```c
const int trigPin = 9;   // Pin for ultrasonic sensor trig
const int echoPin = 10;  // Pin for ultrasonic sensor echo
const int leftMotorForward = 2;  // Pin for left motor forward movement
const int rightMotorForward = 4;  // Pin for right motor forward movement
void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(leftMotorForward, OUTPUT);
  pinMode(rightMotorForward, OUTPUT);
}
void loop() {
  int distance = getDistance();
  if (distance < 20) { // If obstacle is within 20cm
    stopMotors();
    delay(500);
    turnAround();
  } else {
    moveForward();
  }
  delay(50);
}
int getDistance() {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  int duration = pulseIn(echoPin, HIGH);
  int distance = duration  0.034 / 2;
  return distance;
}
void moveForward() {
  digitalWrite(leftMotorForward, HIGH);
  digitalWrite(rightMotorForward, HIGH);
}
void stopMotors() {
  digitalWrite(leftMotorForward, LOW);
  digitalWrite(rightMotorForward, LOW);
}
void turnAround() {
  digitalWrite(leftMotorForward, LOW);
  digitalWrite(rightMotorForward, HIGH);
  delay(500);
  digitalWrite(leftMotorForward, HIGH);
  digitalWrite(rightMotorForward, LOW);
  delay(500);
}
```
### Example 3: Line Following using Line Tracking Sensor
This example demonstrates how to use the line tracking sensor to follow a black line on a white surface.
```c
const int leftSensor = A0;  // Pin for left line tracking sensor
const int centerSensor = A1; // Pin for center line tracking sensor
const int rightSensor = A2;  // Pin for right line tracking sensor
const int leftMotorForward = 2;  // Pin for left motor forward movement
const int rightMotorForward = 4;  // Pin for right motor forward movement
void setup() {
  pinMode(leftSensor, INPUT);
  pinMode(centerSensor, INPUT);
  pinMode(rightSensor, INPUT);
  pinMode(leftMotorForward, OUTPUT);
  pinMode(rightMotorForward, OUTPUT);
}
void loop() {
  int leftValue = analogRead(leftSensor);
  int centerValue = analogRead(centerSensor);
  int rightValue = analogRead(rightSensor);
if (centerValue < 500) { // If center sensor detects the line
    moveForward();
  } else {
    if (leftValue < 500) { // If left sensor detects the line
      turnLeft();
    } else if (rightValue < 500) { // If right sensor detects the line
      turnRight();
    } else {
      stopMotors();
    }
  }
  delay(50);
}
void moveForward() {
  digitalWrite(leftMotorForward, HIGH);
  digitalWrite(rightMotorForward, HIGH);
}
void turnLeft() {
  digitalWrite(leftMotorForward, LOW);
  digitalWrite(rightMotorForward, HIGH);
  delay(200);
}
void turnRight() {
  digitalWrite(leftMotorForward, HIGH);
  digitalWrite(rightMotorForward, LOW);
  delay(200);
}
void stopMotors() {
  digitalWrite(leftMotorForward, LOW);
  digitalWrite(rightMotorForward, LOW);
}
```
Troubleshooting
Ensure proper connections between components.
 Verify power supply voltage and current ratings.
 Check for software errors and debugging messages.
Resources
[Datasheet for ATmega328P microcontroller](https://www.microchip.com/wwwdatasheets/ATmega328P.pdf)
 [L298N motor driver datasheet](https://www.st.com/resource/en/datasheet/l298n.pdf)
 [Ultrasonic sensor datasheet](https://www.maxbotix.com/documents/HRLV-MaxSonar-EZ_Datasheet.pdf)
Note: The examples provided are for illustrative purposes only and may require modifications based on specific requirements and application scenarios.