180 x 120 x 50 mm
180 x 120 x 50 mm
2 x DC Gear Motors
Up to 150 RPM
7.4V, 1200mAh Li-ion Battery
Arduino, Raspberry Pi, ESP32
Ultrasonic, Infrared, Line-Tracking Sensors
| I/O Ports | USB, UART, GPIO |
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.
2WD Two Wheel Drive DIY Kit - A Smart Robot Car with ChassisOverviewThe 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 SpecificationsMicrocontroller 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 supplyGetting StartedBefore 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 ControlThis 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 movementvoid 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 SensorThis 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 movementvoid 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 SensorThis 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 movementvoid 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);
}
```TroubleshootingEnsure 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.