DIY D2-1 Intelligent Line Follower/Tracing Car Kit
DIY D2-1 Intelligent Line Follower/Tracing Car Kit
The DIY D2-1 Intelligent Line Follower/Tracing Car Kit is a comprehensive and interactive robotics kit designed for enthusiasts, hobbyists, and students to explore the world of robotics and automation. This kit enables users to build and program a line-following car that can detect and track a specific path, making it an ideal project for learning about robotics, artificial intelligence, and IoT concepts.
| The DIY D2-1 Intelligent Line Follower/Tracing Car Kit is designed to perform the following functions |
Arduino Uno
5 x IR Sensors
L298N Dual H-Bridge Motor Driver
Rechargeable 6V 1000mAh Battery Pack, USB Interface
150 x 100 x 50 mm (Car Body), 70 x 50 x 20 mm (Control Panel)
approximately 250g (Car Body), 50g (Control Panel)
Arduino IDE
| The DIY D2-1 Intelligent Line Follower/Tracing Car Kit is suitable for a variety of applications, including |
DIY D2-1 Intelligent Line Follower/Tracing Car Kit
Arduino Uno Board
Infrared Sensors (5 x)
Motor Driver (L298N)
Rechargeable Battery Pack (6V 1000mAh)
USB Cable
Assembly Manual
Programming Guide
DIY D2-1 Intelligent Line Follower/Tracing Car Kit DocumentationOverviewThe DIY D2-1 Intelligent Line Follower/Tracing Car Kit is a highly integrated and affordable IoT component designed for robotics and automation projects. It allows users to build a line-following robot car that can detect and follow a black line on a white surface. The kit includes an Arduino-compatible microcontroller board, motor driver, sensory modules, and other necessary components.Technical SpecificationsMicrocontroller: Arduino-compatible ATmega328P
Sensor: Infrared reflective sensor ( TCRT5000 )
Motor Driver: L298N dual H-bridge motor driver
Power Supply: 6-12V DC
Communication: Serial communication through USBCode Examples### Example 1: Basic Line Follower using Arduino IDEThis example demonstrates how to use the DIY D2-1 Intelligent Line Follower/Tracing Car Kit to follow a black line on a white surface using the Arduino IDE.```cpp
const int leftMotorForward = 2; // Pin for left motor forward
const int leftMotorBackward = 3; // Pin for left motor backward
const int rightMotorForward = 4; // Pin for right motor forward
const int rightMotorBackward = 5; // Pin for right motor backwardconst int leftSensor = A0; // Pin for left sensor
const int rightSensor = A1; // Pin for right sensorvoid setup() {
pinMode(leftMotorForward, OUTPUT);
pinMode(leftMotorBackward, OUTPUT);
pinMode(rightMotorForward, OUTPUT);
pinMode(rightMotorBackward, OUTPUT);
}void loop() {
int leftValue = analogRead(leftSensor);
int rightValue = analogRead(rightSensor);if (leftValue > 500 && rightValue > 500) {
// Move forward
digitalWrite(leftMotorForward, HIGH);
digitalWrite(rightMotorForward, HIGH);
} else if (leftValue < 500 && rightValue > 500) {
// Turn right
digitalWrite(rightMotorForward, HIGH);
digitalWrite(leftMotorBackward, HIGH);
} else if (leftValue > 500 && rightValue < 500) {
// Turn left
digitalWrite(leftMotorForward, HIGH);
digitalWrite(rightMotorBackward, HIGH);
} else {
// Stop
digitalWrite(leftMotorForward, LOW);
digitalWrite(rightMotorForward, LOW);
}delay(50);
}
```### Example 2: Advanced Line Follower with Speed Control using Python and PySerialThis example demonstrates how to use the DIY D2-1 Intelligent Line Follower/Tracing Car Kit with Python and PySerial to follow a black line on a white surface with speed control.```python
import serial# Initialize serial communication
ser = serial.Serial('COM3', 9600) # Replace 'COM3' with your serial portwhile True:
# Read sensor values
left_value = int(ser.readline().decode().strip())
right_value = int(ser.readline().decode().strip())# Calculate motor speeds
if left_value > 500 and right_value > 500:
# Move forward
left_speed = 255
right_speed = 255
elif left_value < 500 and right_value > 500:
# Turn right
left_speed = 128
right_speed = 255
elif left_value > 500 and right_value < 500:
# Turn left
left_speed = 255
right_speed = 128
else:
# Stop
left_speed = 0
right_speed = 0# Send motor speed commands
ser.write(f"L{left_speed}
".encode())
ser.write(f"R{right_speed}
".encode())# Wait for 50ms
time.sleep(0.05)
```### Example 3: Line Follower with Obstacle Avoidance using InterruptsThis example demonstrates how to use the DIY D2-1 Intelligent Line Follower/Tracing Car Kit with interrupts to follow a black line on a white surface while avoiding obstacles.```cpp
const int leftMotorForward = 2; // Pin for left motor forward
const int leftMotorBackward = 3; // Pin for left motor backward
const int rightMotorForward = 4; // Pin for right motor forward
const int rightMotorBackward = 5; // Pin for right motor backwardconst int leftSensor = A0; // Pin for left sensor
const int rightSensor = A1; // Pin for right sensor
const int obstacleSensor = 6; // Pin for obstacle sensorvolatile bool obstacleDetected = false;void setup() {
pinMode(leftMotorForward, OUTPUT);
pinMode(leftMotorBackward, OUTPUT);
pinMode(rightMotorForward, OUTPUT);
pinMode(rightMotorBackward, OUTPUT);
pinMode(obstacleSensor, INPUT);attachInterrupt(digitalPinToInterrupt(obstacleSensor), obstacleDetect, RISING);
}void loop() {
int leftValue = analogRead(leftSensor);
int rightValue = analogRead(rightSensor);if (obstacleDetected) {
// Avoid obstacle
digitalWrite(leftMotorForward, LOW);
digitalWrite(rightMotorForward, LOW);
delay(500);
obstacleDetected = false;
} else {
if (leftValue > 500 && rightValue > 500) {
// Move forward
digitalWrite(leftMotorForward, HIGH);
digitalWrite(rightMotorForward, HIGH);
} else if (leftValue < 500 && rightValue > 500) {
// Turn right
digitalWrite(rightMotorForward, HIGH);
digitalWrite(leftMotorBackward, HIGH);
} else if (leftValue > 500 && rightValue < 500) {
// Turn left
digitalWrite(leftMotorForward, HIGH);
digitalWrite(rightMotorBackward, HIGH);
} else {
// Stop
digitalWrite(leftMotorForward, LOW);
digitalWrite(rightMotorForward, LOW);
}
}delay(50);
}void obstacleDetect() {
obstacleDetected = true;
}
```These examples demonstrate the capabilities of the DIY D2-1 Intelligent Line Follower/Tracing Car Kit and provide a starting point for various IoT projects.