Uploaded by Francis Lopez

Act-2-Color-Sorter-v0.6

advertisement
ECEELEC4
Elective 4 (Microprocessor System)
01 / 1 / 19
SBEE - 4A
ALAMO, LOPEZ,
PEREZ, TORMIENTO
PROF. JOSELITO A. TRINIDAD,
MTE
I. Title : COLOR SORTER SYSTEM
II. Objectives
Be able to;
 Construct a color sensing and color sorter system.
 Utilize a microcontroller.
 Program the system using embedded system
III. List of Materials/Tools/Equipment
1. Color sensor module
2. Servo Motor
3. Microcontroller Comp.
4. Connecting wires
5. Breadboard
6. Compiler program
IV. Block Diagram
V. Methodology / Procedure
1. Gather all the necessary materials
2. Using the Data Sheet, construct the wiring diagram.
3. Make the program in an embedded system.
4. Configure your circuit having to identify at least 5 colors.
5. Connect a color in your sensor it must be represented in the OUTPUT Servo Motor
VI. Flow Chart / Schematic Diagram
 Schematic Diagram

Flow Chart
VII. Algorithm and Program Codes
 Program Codes
// Activity 2 of
Microcontroller/Microprocessor
// Color Sensor with Servo Motor
#include <Servo.h> // The library of servo
motor which includes to run the program.
#define S0 2 // S0 of the Color Sensor
Module is connected to pin 2 of the Arduino
Uno R3
ECEELEC4
Elective 4 (Microprocessor System)
01 / 1 / 19
SBEE - 4A
ALAMO, LOPEZ,
PEREZ, TORMIENTO
PROF. JOSELITO A. TRINIDAD,
MTE
#define S1 3 // S1 of the Color Sensor
Module is connected to pin 3 of the Arduino
Uno R3
#define S2 4 // S2 of the Color Sensor
Module is connected to pin 4 of the Arduino
Uno R3
#define S3 5 // S3 of the Color Sensor
Module is connected to pin 5 of the Arduino
Uno R3
#define OUT 6 // OUT of the Color Sensor
Module is connected to pin 6 of the Arduino
Uno R3
int ReadFrequencies = 0; //default reading
frequency is equal to 0.
int ReadColors = 0; //default reading color is
equal to zero.
Servo SV1; // Naming the Servo to SV1
void setup() {
//Setting up the INPUT and OUTPUT of
the system
pinMode(S0, OUTPUT); // Setting up the
S0 as output
pinMode(S1, OUTPUT); // Setting up the
S1 as output
pinMode(S2, OUTPUT); // Setting up the
S2 as output
pinMode(S3, OUTPUT); // Setting up the
S3 as output
pinMode(OUT, INPUT); // Setting up the
OUT as input
//Initial Setup for frequency scaling: 20%
digitalWrite(S0, HIGH);
digitalWrite(S1, LOW);
//Setting up the Serial port
Serial.begin(9600);
//Servo
SV1.attach(9); // Servo motor is connect
on Pin9
SV1.write(90); //
}
void loop() {
// Setting red filtered photodiodes to be
read
digitalWrite(S2, LOW);
digitalWrite(S3, LOW);
// Reading the output frequency
ReadFrequencies = pulseIn(OUT, LOW);
int Red = ReadFrequencies;
delay(50);
// Setting the green filtered photodiodes to
be read
digitalWrite(S2, HIGH);
digitalWrite(S3, HIGH);
// Read the output frequency
ReadFrequencies = pulseIn(OUT, LOW);
int Green = ReadFrequencies;
delay(50);
// Setting blue filtered photodiodes to be
read
digitalWrite(S2, LOW);
digitalWrite(S3, HIGH);
// Reading the output frequency
ReadFrequencies = pulseIn(OUT, LOW);
int Blue = ReadFrequencies;
delay(50);
if(Red<34 & Red>30 & Green<125 &
Green>113){
SV1.write(34); //Servo moves at
34degrees
Serial.println("Red");
}
if(Green<33 & Green>27 & Blue<37
&Blue>34){
SV1.write(68); //Servo moves at
68degrees
Serial.println("Orange");
}
if(Red<64 & Red>56 & Green<53 &
Green>45){
SV1.write(102); //Servo moves at
102degrees
Serial.println("Green");
ECEELEC4
Elective 4 (Microprocessor System)
01 / 1 / 19
SBEE - 4A
ALAMO, LOPEZ,
PEREZ, TORMIENTO
PROF. JOSELITO A. TRINIDAD,
MTE
}
if(Red<19 & Red>13 & Green<24 &
Green>18){
SV1.write(136); //Servo moves at
136degrees
Serial.println("Yellow");
SV1.write(170); //Servo moves at
170degrees
Serial.println("Blue");
}
if (Green<44 & Green>35 & Blue<25 &
Blue>17){
}
}
return ReadColors;
 Algorithm
Step 1: Start
Step 2: Servo motor library includes
Step 3: S0 of the Color Sensor Module is connected to pin 2 of the Arduino Uno R3
Step 4: S1 of the Color Sensor Module is connected to pin 3 of the Arduino Uno R3
Step 5: S2 of the Color Sensor Module is connected to pin 4 of the Arduino Uno R3
Step 6: S3 of the Color Sensor Module is connected to pin 5 of the Arduino Uno R3
Step 7: OUT of the Color Sensor Module is connected to pin 6 of the Arduino Uno R3
Step 8: Setting up the S0 as output
Step 9: Setting up the S1 as output
Step 10: Setting up the S2 as output
Step 11: Setting up the S3 as output
Step 12: Setting up the OUT as input
Step 13: Initial Setup for frequency scaling: 20%
Step 14: Setting up the Serial port
Step 15: Servo motor is connect on Pin9
Step 16: Setting red filtered photodiodes to be read (S2 and S3 is LOW)
Step 17: Reading the output frequency (int Red = ReadFrequencies)
Step18: Setting the green filtered photodiodes to be read (S2 and S3 is HIGH)
Step 19: Read the output frequency (int Green = ReadFrequencies)
Step 20: Setting blue filtered photodiodes to be read (S2 is LOW and S3 is HIGH)
Step 21: Reading the output frequency (int Blue = ReadFrequencies)
Step 22: If the color sensor read a RED color
Step 23: Servo moves at 34 degrees
Step 24: If the color sensor read an ORANGE color
Step 25: Servo moves at 68 degrees
Step 26: If the color sensor read a GREEN color
Step 27: Servo moves at 102 degrees
Step 28: If the color sensor read a YELLOW color
Step 29: Servo moves at 136 degrees
Step 30: If the color sensor read a BLUE color
Step 31: Servo moves at 170 degrees
Step 32: End
VIII. Data Sheet
1. Arduino UNO
ECEELEC4
Elective 4 (Microprocessor System)
01 / 1 / 19
SBEE - 4A
ALAMO, LOPEZ,
PEREZ, TORMIENTO
PROF. JOSELITO A. TRINIDAD,
MTE
2. Color Sensor
ECEELEC4
Elective 4 (Microprocessor System)
01 / 1 / 19
SBEE - 4A
ALAMO, LOPEZ,
PEREZ, TORMIENTO
PROF. JOSELITO A. TRINIDAD,
MTE
3. Servo Motor
ECEELEC4
Elective 4 (Microprocessor System)
01 / 1 / 19
SBEE - 4A
ALAMO, LOPEZ,
PEREZ, TORMIENTO
PROF. JOSELITO A. TRINIDAD,
MTE
IX. Eperimental Set-up
Actual Set-Up
Color Sensor : RED ; Servo @ 34°
Color Sensor : ORANGE ; Servo @ 68°
Color Sensor : GREEN ; Servo @ 102°
ECEELEC4
Elective 4 (Microprocessor System)
01 / 1 / 19
SBEE - 4A
ALAMO, LOPEZ,
PEREZ, TORMIENTO
PROF. JOSELITO A. TRINIDAD,
MTE
Color Sensor : YELLOW ; Servo @ 136°
Color Sensor : BLUE ; Servo @ 170°
X. Analyzation
Our observation will be the same because we only change the output which is RGB and
the new output is the servo. We also observe that servo has different angle which can help us
mechanically arrange in sorting the color of a thing.
In this activity we need to make a color sensor with a servo motor as a sorter of an
object. When the color sensor read a color RED object the servo will move at 34 degrees from
the initial sides, When the color sensor read a color ORANGE object the servo will move at 68
degrees from the initial sides, When the color sensor read a color GREEN object the servo will
move at 102 degrees from the initial side, When the color sensor read a color YELLOW object
the servo will move at 136 degrees from the initial side, When the color sensor read a color
BLUE object the servo will move at 170 degrees, and when the sensor read a different color
object the servo motor shaft will remain at the previous position.
XI. Conclusion
Therefore when the color sensor read an object and when the object color is based on
the specific colors in the program, The position of the servo motor will rotate according to the
color of the object. This principle will can apply in a color sorter when the sensor has a
different colored object the servo motor will sort the object in a specific position or place.
Download
Random flashcards
Radiobiology

39 Cards

Pastoralists

20 Cards

Radioactivity

30 Cards

Nomads

17 Cards

Ethnology

14 Cards

Create flashcards