Grouping Project Electronic
Grouping Project Electronic
PREPARED BY:
1
VRT3043
Table of Contents
2
VRT3043
1.0 INTRODUCTION
This project entails building and testing a 2WD Smart Robot Car with the "Arduino 2WD
Smart Robot Car Set DIY," which was obtained from an online retailer. The kit is intended to
provide a low-cost and hands-on approach to learning about robotics, electronics, and
programming, making it an excellent educational resource for students, hobbyists, and
educators. It contains essential components such as an Arduino Uno board, a motor driver,
DC geared motors, wheels, a micro servo, an ultrasonic sensor, and all mounting hardware.
The primary goal of this project is to design and programme a robotic vehicle capable
of autonomous navigation. To detect obstacles, the robot uses an ultrasonic sensor, and the
motor driver controls the wheels using sensor input processed by the Arduino Uno board.
This integration of components enables the robot to move, detect obstacles, and adjust its
path as needed. The project includes a variety of control systems, including:
1. Mechanical System: This includes structural elements such as the acrylic chassis,
wheels, and hammer caster that are necessary for the robot's movement and stability.
2. Electronic System: This system is centred on the Arduino Uno board and includes
the L298 motor driver and sensor shield, which enable communication between
sensors and actuators.
3. Electric System: This system, which is made up of the battery box and wiring,
ensures a consistent power supply to all components.
4. Control System: The ultrasonic sensor and microservo work together to detect
obstacles and adjust the robot's direction, demonstrating the robot's autonomous
operation.
This project provides invaluable insights into the integration and operation of various
robotic systems. Assembling and programming the 2WD Smart Robot Car provides hands-on
experience that highlights the practical applications of robotics and automation technologies,
emphasising their interdisciplinary nature and importance in today's world.
3
VRT3043
The circuit diagram illustrates the interconnections and constituent parts used in the
electronic system of the 2WD Smart Robot Car. The following is an elaborate circuit diagram
that illustrates the arrangement of electrical components in the circuit:
4
VRT3043
The circuit operating process elucidates the manner in which the electronic components
collaborate and operate in unison, facilitating the 2WD Smart Robot Car's efficient
navigation and obstacle avoidance. The following is a detailed explanation of the operating
process:
1. Activating:
● When the battery box is connected to the robot car, power is supplied to the
Arduino Uno board and other electronic components, which start the system.
2. Sensor Initialization:
● The HC-SR04 ultrasonic sensor is activated and prepared to detect obstacles in
the robot's path as soon as power is supplied.
3. Obstacle Detection:
● The ultrasonic sensor emits sound waves with a high frequency and measures
the time it takes for the waves to return after colliding with an obstacle.
● The sensor uses the time it takes for sound waves to return to calculate the
distance to the obstacle in front of the robot.
4. Data Processing:
● The Arduino Uno board receives the distance measurements from the
ultrasonic sensor and performs computations on this data.
● The Arduino uses predefined threshold values to compare the measured
distance and ascertain whether an obstacle is within a critical range.
5. Decision Making:
● When the measured distance indicates that an obstacle is within the critical
range, the Arduino activates the navigation algorithm to circumvent the
obstacle.
● The navigation algorithm computes the motor control signals by considering
the obstacle's position in relation to the robot.
6. Motor Control:
● The Arduino transmits control signals to the L298 motor driver board in order
to regulate the velocity and orientation of the DC geared motors.
● The motor driver interprets the signals and adjusts the motor outputs
accordingly, enabling the robot to manoeuvre around the obstacle.
5
VRT3043
7. Servo Adjustment:
● The micro servo SG90 is used to adjust the position of the ultrasonic sensor in
order to scan for obstacles over a wider range simultaneously. This calibration
guarantees that the robot is capable of detecting obstacles not only directly in
front of it but also in its vicinity.
8. Continuous operation:
● The robot's obstacle detection, data processing, decision making, motor
control, and servo adjustment processes occur continuously and repeatedly as
the robot moves, guaranteeing uninterrupted navigation and avoidance of
obstacles.
Because of its circuit operating process, the 2WD Smart Robot Car is capable of
autonomously navigating and avoiding obstacles in its environment. The robot car can
effectively function in different situations by incorporating sensor data processing,
decision-making algorithms, and motor control mechanisms. Understanding the operational
procedure is essential for programming and improving the robot's behavior to achieve desired
navigation results.
6
VRT3043
Mechanical Systems
1 Acrylic Chassis Acts as the main structural base for mounting all the
components, providing stability and support for the
entire robot.
7
VRT3043
Electronic system
2 L298 Motor Driver Controls the speed and direction of the DC motors
by receiving control signals from the Arduino and
providing the necessary current and voltage to the
motors.
8
VRT3043
Electric System
Control System
9
VRT3043
1 DC Geared Motors Provide the necessary torque and speed to drive the
wheels, enabling the robot's movement.
● Arduino Uno Board: Central control unit for processing inputs and executing control
commands.
● L298 Motor Driver: Manages motor speed and direction based on Arduino signals.
● Ultrasonic Sensor: Detects obstacles by measuring distance through ultrasonic waves.
● Wheels: Facilitate movement.
● Hammer Caster: Enhances stability and balance.
● Micro Servo: Rotates the ultrasonic sensor for environmental scanning.
● Battery Box: Supplies power to all components.
● Wiring: Ensures electrical connectivity and signal transmission.
● Acrylic Chassis: Provides structural support.
10
VRT3043
11
VRT3043
12
VRT3043
13
VRT3043
14
VRT3043
Step 6: Assemble the Motor Driver Board and Arduino Uno Board
15
VRT3043
16
VRT3043
6.0 CODE
/*
2WD Demo code by https://www.gie.com.my
Using
- Arduino Uno Compatible
- Arduino Sensor Shield
- L298 Motor Driver Module
- Ultrasnic Sensor
- Servo SG90s
*/
#include <Servo.h>
Servo myservo;
void setup() {
pinMode(Left_A, OUTPUT);
pinMode(Left_B, OUTPUT);
pinMode(SpeedA, OUTPUT);
pinMode(Right_A, OUTPUT);
pinMode(Right_B, OUTPUT);
pinMode(SpeedB, OUTPUT);
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
17
VRT3043
myservo.write(90);
delay(500);
servoDemo();
delay(500);
myservo.write(90);
delay(500);
setSpeed(150);
forward();
delay(5000); //moving forward for 5 second
backward();
delay(5000); //moving backward for 5 second
stopmoving(); //stop moving
delay(1000);
turnleft();
delay(5000); //turn left for 5 second
stopmoving(); //stop moving
delay(1000);
turnright();
delay(5000); //turn right for 5 second
stopmoving(); //stop moving
delay(1000);
void servoDemo() {
int pos = 0;
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15 ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15 ms for the servo to reach the position
}
}
18
VRT3043
analogWrite(SpeedA, value);
analogWrite(SpeedB, value+40);
}
void stopmoving() {
digitalWrite(Left_A, HIGH);
digitalWrite(Left_B, HIGH);
digitalWrite(Right_A, HIGH);
digitalWrite(Right_B, HIGH);
}
void backward() {
digitalWrite(Left_A, HIGH);
digitalWrite(Left_B, LOW);
digitalWrite(Right_A, HIGH);
digitalWrite(Right_B, LOW);
delay(STEPS);
}
void forward() {
digitalWrite(Left_A, LOW);
digitalWrite(Left_B, HIGH);
digitalWrite(Right_A, LOW);
digitalWrite(Right_B, HIGH);
delay(STEPS);
}
void turnleft() {
digitalWrite(Left_A, HIGH);
digitalWrite(Left_B, HIGH);
digitalWrite(Right_A, LOW);
digitalWrite(Right_B, HIGH);
delay(STEPS);
}
void turnright() {
digitalWrite(Left_A, LOW);
digitalWrite(Left_B, HIGH);
digitalWrite(Right_A, HIGH);
digitalWrite(Right_B, HIGH);
delay(STEPS);
}
stopmoving();
19
VRT3043
myservo.write(150);
delay(300);
cm150 = getDistance();
myservo.write(30);
delay(300);
cm30 = getDistance();
delay(300);
myservo.write(90);
delay(50);
void rightCircle() {
digitalWrite(Left_A, LOW);
digitalWrite(Left_B, HIGH);
digitalWrite(Right_A, HIGH);
digitalWrite(Right_B, LOW);
}
void leftCircle() {
digitalWrite(Left_A, HIGH);
digitalWrite(Left_B, LOW);
digitalWrite(Right_A, LOW);
digitalWrite(Right_B, HIGH);
}
long getDistance() {
long cm, duration;
20
VRT3043
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
cm = microsecondsToCentimeters(duration);
return cm;
}
void loop(){
if (leftOrRight == true) {
turnleft();
delay(500);
stopmoving();
}
else {
turnright();
delay(500);
stopmoving();
}
}
}
21
VRT3043
7.0 CONCLUSION
22