PIA IntroMecatronica
PIA IntroMecatronica
Introduction to mechatronics
Name ID Career
Darío Israel Barrera Martínez 2067873
Javier Kalid Flores Edgar 2177781 IMC
Yareidy Michell Silverio Gaspar 2115243
Index
Objectives 2
Introduction 4
List of materials 5
Development 6
Steps: 6
Systems 8
Results 10
Conclusions 11
References 12
Objectives
The main objective of this project is to successfully create a line-following robot by applying
knowledge in mechanics, electronics and/or software that can autonomously detect and follow
a trajectory marked on the ground in the shortest possible time. Other secondary objectives
include:
2
• Create a robot that can accurately follow a drawn line on a variety of surfaces, including
regular and irregular curves.
• Maximize robot speed while maintaining stability and line tracking accuracy.
• Ensure stable operation with sensors that adapt to changes in light and environment and
perform consistently regardless of external factors.
• Controls up to two DC motors with a 48:1 ratio and uses H-bridge motor control for precise
motion.
• Perform extensive testing to fine-tune sensors and control algorithms for optimal running
performance.
3
Introduction
4
List of materials
• Chassis components:
- Base platform (plastic)
- 2 Yellow rims (65mm diameter with a tolerance of ±3mm).
- 1 idler wheel.
• Motors:
- 2 hobby gear motors (model specific details as required): The two DC
motors drive the wheels of the robot, providing movement. Their speed and
direction can be controlled based on sensor input processed by the Arduino.
• Sensors:
- 2 IR sensors (for line detection): Are essential for detecting the line that the
robot is intended to follow. They work by emitting infrared light, which
reflects off the surface below and returns to the sensor. This allows the robot
to differentiate between the line and the surrounding area based on the
intensity of the reflected light.
• Microcontroller
- Arduino UNO R3: serves as the brain of your robot. It processes input from
the IR sensors and controls the motors based on this data. Its
programmability allows for complex decision-making algorithms that can
optimize performance.
- Arduino shield: Are expansion boards that connect to Arduino boards,
adding different features. They simplify project enhancements without
complex wiring.
• Power supply:
- 2 batteries 9V non-rechargeable battery to power the motor and to power
the control system: Provides the necessary power to both the
microcontroller and motors. A reliable power source is critical for consistent
performance; insufficient power can lead to sluggish movement or erratic
behavior
• Miscellaneous components:
- Protoboards for circuit assembly
- Connection Cables
- Mounting and fixing components.
5
Development
Steps:
These steps outline the development of our line follower robot, detailing the processes
we undertook, the challenges faced, and the solutions implemented. Our project involved
studying infrared (IR) sensors, integrating an Arduino shield for motor control, and coding
the system to achieve effective line-following behavior.
The first phase of our project focused on understanding the behavior of IR sensors. We
conducted experiments to observe how these sensors detect changes in surface color—
specifically, distinguishing between black and white surfaces. This foundational
knowledge was crucial as it directly influenced our design and programming decisions.
Key Findings:
- Placement: Proper sensor alignment was essential for accurate detection, leading us to
experiment with various mounting angles to optimize performance.
In the second step, we integrated an Arduino shield designed for controlling motors. This
shield served as both a motor driver and a controller for our robot's system. The shield
simplified connections and provided an efficient way to manage power and signals
between the Arduino and the motors.
Components Used:
- Motor Driver Shield: Facilitated control over motor speed and direction.
The final step involved programming the Arduino to respond to sensor inputs and control
the motors accordingly. Below is the code developed for this purpose:
void setup() {
// Initialize serial communication
Serial.begin(9600);
6
// Pin configuration
pinMode(7, INPUT); // Left IR sensor
pinMode(9, INPUT); // Right IR sensor
pinMode(2, OUTPUT); // Motor control pin
pinMode(5, OUTPUT); // Left motor speed
pinMode(4, OUTPUT); // Left motor direction
pinMode(6, OUTPUT); // Right motor speed
}
void loop() {
// Main loop code
int Left_Tra_Value = digitalRead(7);
int Right_Tra_Value = digitalRead(9);
int Black = 1;
Code Explanation:
7
- Setup Function: Initializes serial communication and configures pins for sensors and
motors.
- Loop Function: Continuously reads sensor values and adjusts motor speeds based on
detected colors. Logic ensures that the robot follows the line by responding dynamically
to changes in its environment.
Systems
The control system of our line follower robot is built around an Arduino shield, which
simplifies the integration of motors and sensors. This system allows the robot to
autonomously follow a line by processing input from infrared (IR) sensors and controlling
the motors accordingly.
1. IR Sensors:
• The robot is equipped with two IR sensors positioned at the front. These
sensors detect the color of the surface beneath them, distinguishing
between black (the line) and white (the background).
• The sensors provide digital signals to the Arduino, indicating whether they
detect black or white.
2. Arduino Shield:
• The Arduino shield used in this project is designed specifically for motor
control, allowing for easy connection and control of DC motors without
requiring additional components like a separate motor driver.
• This shield can control multiple motors and is equipped with features that
simplify wiring and programming.
3. DC Motors:
• The motors are responsible for driving the robot. The Arduino shield controls
their speed and direction based on sensor inputs.
Control Logic
The control logic implemented in the Arduino code is designed to respond dynamically to
sensor readings, enabling effective line-following behavior. Here’s how it works:
• Setup Phase:
• The setup () function initializes serial communication and configures pins for
IR sensors and motor controls.
• Loop Phase:
• The loop () function continuously reads values from the IR sensors:
• If both sensors detect white, the robot moves forward.
• If only the left sensor detects black, it turns right by adjusting motor
speeds.
• If only the right sensor detects black, it turns left.
8
• If both sensors detect black, it stops to prevent going off course.
• Motor Control: The shield allows for precise control over each motor's speed and
direction through PWM (Pulse Width Modulation) signals. This enables smooth
operation and responsive adjustments based on sensor input. The shield
distributes the current and ground connections evenly to the whole circuit, allowing
for a faster and more organized cable layout, as well as a more optimized energy
management.
The shield also allowed for speed control directly within the arduino code, instead
of relying on an external component such as a motor H bridge.
9
Results
As proposed initially, the structure of the project was made as lightweight as possible, to
minimize the strain of the wheels, as well as ensure proper functioning of the sensors.
When executed, the robot functioned properly, closely following the line deemed as the path,
and was even able to overcome uncertainties such as really closed corners.
The code permitted the robot to turn rapidly and in tight spaces, but one downside that can be
noted is the battery consumption since it depleted the units relatively quickly due to the energy
demand required to make the engines work at said rate.
10
Conclusions
Line follower robots (LFRs) utilize specific techniques to detect and follow lines based on
the principles of light reflection. To exploit this property, infrared (IR) sensors are
employed due to their precision in detecting light variations. In our project, three IR
sensors are strategically placed on either side of the robot and in the middle of it to identify
the line beneath it.
The development of our LFR has been an enriching and educational experience that
deepened our understanding of robotics and automation. Initially approached with
confidence, the project presented a series of challenges that required us to adapt, learn,
and innovate. Through practical experimentation with IR sensors, motor control using an
Arduino shield, and coding, we were able to create a functional robot capable of
autonomously following a line.
The robot executes four primary actions based on sensor input: moving forward when the
middle sensor detects black while the side sensors detect white; turning left when the left
sensor detects black; turning right when the right sensor detects black; and stopping when
all three sensors detect black simultaneously. The motors are programmed to rotate in
opposite directions to facilitate these movements, allowing the robot to navigate
effectively along the designated black line. This systematic approach enables line follower
robots to follow paths accurately and respond dynamically to changes in their
environment.
11
References
• Instructables. (n.d.). Arduino - Line Follower Robot: 8 Steps (with Pictures). Retrieved
from https://www.instructables.com/Arduino-Line-Follower-Robot-1/
• Technuttiez. (2019, April 3). How to make line follower robot using Arduino. Hackster.io.
Retrieved from https://www.hackster.io/technuttiez/how-to-make-line-follower-robot-
using-arduino-c886de
• Instructables. (n.d.). Line Follower Robot Arduino and L293D Shield: 4 Steps. Retrieved
from https://www.instructables.com/Line-Follower-Robot-Arduino-and-L293D-Shield/
• Whadda. (2021, April 2). Make a one sensor line follower with the Arduino STEM shield.
Retrieved from https://whadda.com/make-a-one-sensor-line-follower-with-the-arduino-
stem-shield/
• YouTube. (2020, March 22). How to make a Line Follower Robot Car Using Arduino
L293d and IR. Retrieved from https://www.youtube.com/watch?v=Jmbxb0Yq6Cg
12
Annexes
• During the assembly process we decided that it would be a good idea to implement an
ultrasonic sensor together with a servo motor to make our robot more efficient, and
although due to some setbacks it was not possible to implement it for the final delivery,
we are still working on it for the next competition.
• Throughout all the process we had to make different changes to our first design due to
different things that came up, but even so we were able to end the project with a good
robot that was able to follow the proposed line.
• Determining the circuit that the robot would follow was a relevant part not previously
considered, since the sensors and speed had to be calibrated in accordance with the
circuit requirements and its layout in general, such as sharp curves, long straights,
obstacles, etc...
13