Final Project Report
Final Project Report
Spring 2024
Course ID: MSE 365
Course Name: Introduction to Mechatronics
Student Name ID
Eslam Wael Hussien 223243
Ahmed Ibrahim 222647
Marwan Amr 224293
Ziad Mohamed 221599
Lama Alaa 225213
2
List of Figures
3
Chapter 1: Introduction
1.1Background
The Arduino Color Sorting Machine is a fascinating project that combines electronics,
programming, and mechanical design. It demonstrates how microcontrollers can be used in
automation and robotics to perform specific tasks, in this case, sorting objects based on their
color. This type of project is commonly undertaken by hobbyists, students, and educators to
explore principles of automation, sensors, and control systems.
Working Principle:
1. Feeding Mechanism: Objects are fed into the machine, one at a time or along a
conveyor belt.
2. Color Detection: The color sensor reads the color of the object as it passes by.
3. Processing and Sorting: The Arduino code interprets the sensor data and determines
the object’s color.
4. Servo Actuation: Based on the color, the Arduino sends signals to the servo motors,
which then move the object to the designated bin.
Project Applications:
Sorting M&Ms by color (popular beginner project)
Separating different colored parts in a manufacturing process (industrial application)
Recycling colored objects (educational project on sustainability)
4
Learning Outcomes:
Electronics and programming: Gain hands-on experience with sensors, motors, and
Arduino coding.
Automation concepts: Understand the principles of automated sorting and control
systems.
Problem-solving and design: Develop skills in designing, building, and
troubleshooting a project.
1.2Problem definition
The specific problem addressed by this project is the development of an automated color
sorting machine capable of:
1. Identifying the color of various objects.
2. Sorting these objects into predefined categories based on their color.
3. Operating efficiently and accurately in a controlled environment.
Constraints
1. Environmental Conditions: The system should operate correctly under typical
indoor lighting conditions.
2. Object Specifications: Objects to be sorted should be within a certain size and shape
range for consistent handling.
3. Power Supply: The machine should operate within the power limits of standard
Arduino-compatible components.
Expected Outcomes
1. Prototype Development: Build and test a functional prototype of the Arduino color
sorting machine.
2. Performance Evaluation: Assess the machine’s accuracy, speed, and reliability in
sorting objects by color.
3. Documentation: Provide comprehensive documentation, including design
schematics, code, and a user manual for replication and educational purposes.
Potential Challenges
1. Sensor Calibration: Ensuring the color sensor is properly calibrated to work under
various lighting conditions.
2. Mechanical Design: Designing a robust and efficient mechanical sorting mechanism.
3. System Integration: Seamlessly integrating all components (sensors, motors,
conveyor) with the Arduino.
5
1.3Function requirement
1. Color Sensor Integration: Utilize a color sensor (TCS3200) to detect the color of
objects.
2. Control System: Program the Arduino to process color sensor data and control sorting
mechanisms.
3. Sorting Mechanism: Use servo motors or other actuators to direct objects into the
correct bins based on color.
4. User Interface: Provide a simple interface for users to start, stop, and possibly
calibrate the machine.
1.4Project specification
This report outlines the specifications for an Arduino-based color sorting machine.
4. System Functionality
1. The machine will automatically sort objects based on their color.
2. It will be able to differentiate between a minimum of [X] distinct colors (specify the
desired number of colors).
3. The sorted objects will be directed to separate bins or compartments.
2. Hardware Requirements
1. Microcontroller: Arduino Nano
2. Color Sensor: Suitable for the chosen color range (TCS3200)
3. Servo Motors: Minimum of [2] servos required for the sorting mechanism.
4. Frame or structure to hold everything together (wood)
1.5Current technology
The current technology used in developing an Arduino color sorting machine involves
integrating various electronic components and sensors with mechanical parts to create an
automated system capable of sorting objects by color. This technology leverages
advancements in microcontroller capabilities, sensor accuracy, and motor control to achieve
efficient and reliable sorting.
1. Arduino Microcontroller
Arduino Nano: One of the most popular choices due to its simplicity,
affordability, and extensive community support. It features an ATmega328
microcontroller, 14 digital I/O pins, 8 analog inputs, and operates at 16 MHz.
Other Variants: Depending on the complexity and scale, other Arduino boards
like the Mega (with more I/O pins) or Nano (more compact) may be used.
2. Color Sensors
TCS3200: A programmable color light-to-frequency converter that can detect a
wide range of colors. It consists of an array of photodiodes with filters for red,
green, blue, and no filter.
6
1. Servo Motors
SG90 Servo Motors: Commonly used for their affordability and ease of
control using PWM signals from the Arduino. They are suitable for actuating
sorting mechanisms due to their precision and range of motion.
Software and Programming
1. Arduino IDE
The primary environment for writing, compiling, and uploading code to the Arduino. The
IDE supports C/C++ programming and provides libraries for interfacing with sensors and
motors.
2. Libraries
Servo.h: Arduino library for controlling servo motors.
Wire.h: For I2C communication with sensors like the TCS3200.
7
Chapter 3: Mechanical Design
8
Chapter 4: Electrical Design
Assume the color sensor outputs a value 𝐶C that corresponds to a specific color. This can be
Sensor Model
input: 𝑢=𝑔(𝐶)
The control logic can be represented as a set of rules or a decision matrix based on the sensor
where 𝑔 is the control law that maps the sensor reading to actuator commands.
10
a. Sensor Block
Create a block that simulates the sensor output based on the color of the object. Use a lookup
table or a mathematical function to represent the sensor model.
b. Actuator Block
Model the actuator as a transfer function or a state-space model. Use the transfer function:
K
G ( s )=
τs+1
c. Control Logic Block
Implement the control logic using a combination of logical operators, lookup tables, or a state
machine. This block will take the sensor output and generate the control signal for the
actuator.
d. System Integration
Connect all the blocks together to form the complete system. The sensor block outputs a
signal based on the object's color, the control logic block decides the appropriate bin, and the
actuator block moves the object accordingly.
4. Simulate the Model
Run the simulation in SIMULINK to test the behavior of the color sorting machine. Adjust
parameters and refine the model as needed to achieve the desired performance.
5. Implementing on Arduino
Once the SIMULINK model is validated, you can implement the control algorithm on an
Arduino. Here’s an outline of the Arduino implementation:
a. Setup the Hardware
Connect the color sensor to the Arduino.
Connect the actuators (servos or motors) to the Arduino.
Set up the conveyor belt system.
11
5.2 Mechatronics Simulation (PROTEUS)
12
Chapter 6: Result and discussion
13
An Arduino color sorting machine is a practical and educational project that demonstrates the
power of automation using microcontrollers. Here's a breakdown of the key results and
discussion points:
Results:
Successful Sorting: The machine can effectively separate objects based on their color
with a specified degree of accuracy.
Automation Achieved: The repetitive task of color sorting is automated, saving time
and effort.
Educational Value: The project provides hands-on learning in electronics,
programming, and automation principles.
Discussion:
Accuracy: The achieved accuracy depends on various factors like sensor calibration,
color range complexity, and object variations. Fine-tuning the color thresholds and
potentially using more advanced color sensors can improve accuracy.
Sorting Speed: The throughput depends on the chosen sorting mechanism and the
processing power of the Arduino board. Optimizing the code and using faster servo
motors can enhance speed.
Scalability: The basic design can be adapted to handle different object sizes and
shapes with adjustments to the feeding mechanism and sorting chutes.
Limitations: The processing power of Arduino limits complex color recognition
algorithms. For large-scale industrial applications, more powerful industrial control
systems might be needed.
Conclusion
The Arduino color sorting machine automates color sorting tasks and serves as a great
educational project in electronics, programming, and automation. It can be customized for
various objects but limitations exist in processing power for highly complex tasks.
Advancements in sensor technology and machine learning offer exciting possibilities for
creating more accurate and intelligent sorting machines in the future.
Further Considerations:
14
Improved Sorting Mechanism: Utilizing multiple sensors or more sophisticated
sorting mechanisms can enable the sorting of objects based on multiple colors or
complex sorting criteria.
15
6. Implementation Details
Technical details regarding the Arduino code and its structure.
Pin assignments.
Initialization process.
Control flow for object detection, sorting, and return to initial position.
Overview of the color sorting logic and servo control.
7. Challenges and Considerations
Potential challenges in implementing the color sorting machine.
Considerations for optimizing performance and accuracy.
Possible extensions or improvements to the system.
8. Conclusion
Summary of the Arduino color sorting machine project.
Reflection on its functionality and potential real-world applications.
Encouragement for further exploration or development.
9. References
Citations or links to resources used in designing and implementing the color sorting
machine.
Mention of any external libraries or tools utilized.
16
Appendix C: Electric Drawings
17
Appendix D: Programming Code Listing
#include <Servo.h>
#define S0 2
#define S1 3
#define S2 4
#define S3 5
#define sensorOut 6
Servo topServo;
Servo bottomServo;
int frequency = 0;
int color = 0;
void setup() {
pinMode(S0, OUTPUT);
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
pinMode(sensorOut, INPUT);
digitalWrite(S0, HIGH); //20% scalling
digitalWrite(S1, LOW);
topServo.attach(7);
bottomServo.attach(8);
18
Serial.begin(9600);
}
void loop() {
topServo.write(0); //set top servo at the first hole to catch the candy
delay(500);
for(int i = 0; i <= 55; i++) { //move top servo with the candy to the color sensor position
topServo.write(i);
delay(2);
}
delay(500);
color = readColor(); //read the value from color sensor and put the bottom servo in the right
path
delay(10);
switch (color) {
case 1:
bottomServo.write(0);
break;
case 2:
bottomServo.write(50);
break;
case 3:
bottomServo.write(100);
break;
case 4:
bottomServo.write(70);
case 0:
break;
}
delay(300);
for(int i = 55; i <= 100; i++) { //move top servo with candy from the color sensor position to
the second hole position
topServo.write(i);
delay(2);
}
delay(200);
for(int i = 100; i >= 0; i--) { //return top servo to the first position to catch another candy
topServo.write(i);
delay(2);
19
}
color=0;
}
// Setting red
digitalWrite(S2, LOW);
digitalWrite(S3, LOW);
frequency = pulseIn(sensorOut, LOW);
int R = frequency;
Serial.print("R= ");
Serial.print(frequency);
Serial.print(" ");
delay(50);
// Setting Green
digitalWrite(S2, HIGH);
digitalWrite(S3, HIGH);
frequency = pulseIn(sensorOut, LOW);
int G = frequency;
Serial.print("G= ");
Serial.print(frequency);
Serial.print(" ");
delay(50);
// Setting Blue
digitalWrite(S2, LOW);
digitalWrite(S3, HIGH);
frequency = pulseIn(sensorOut, LOW);
int B = frequency;
Serial.print("B= ");
Serial.print(frequency);
Serial.println(" ");
delay(50);
20
color = 3; // Blue
}
if (G<251 & G>238 & R>211 & R<235 ){
color = 4; // yellow
}
return color;
}
21