SAMPLE PROJECT


Arduino Color Sorter

Abstract: -

All we need for this Arduino project is one color sensor (TCS3200) and two hobbyist servo motors,
which makes this project quite simple but yet very fun tobuild it. In the first place, using the Solid
works 3D modeling software I made the design of the color sorter and here’sits working principle:

Initially, the colored skittles which are held in the charger drop into the platform attached on the
top servo motor.Then the servo motor rotates and brings the skittle to the color sensor which
detects itscolor. After that the bottom servo motor rotates to the particular position and then
the top servo motor rotates again till the skittle drop into the guide rail.


INTRODUCTION: -

The color sorter is a automated assembly of Arduino based equipments which
sorting out objects or products by their color has an important real world application.
These types of machines are often used for sorting fruits, seeds, plastics etc.
The working concept of these machines is rather simple. All you need is a color
detecting sensor and of course a system that feeds the object to the sensor
whiteand then sort it out. Components Used:-







Schematic Representation of Color Sorter.














​​​​​​​​​​TheModel​​​​​​​​​

#Technical Details: -



Color Sensor:

Connect the Digital Pin no. ‘D2,D3,D4,D5,D6’ 
of Arduino to the color sensor in order to detect the

specific R​G​B​​of the object.


-> Connect ‘D2’ with ‘S0’.

-> Connect ‘D3’ with ‘S1’.

-> Connect ‘D4’ with ‘S2’.

-> Connect ‘D5’ with ‘S3’.

-> Connect ‘D6’ with ‘OUT’

Servo Motor:

There are two servo motors used the VCC of both the 
motors connect it with ‘+5v’ and the ground with ‘GND’ 
of the Arduino :-

TOP SERVO MOTOR:

->Connect it with the ‘D7’.

BOTTOM SERVO MOTOR:

->Connect it with the ‘D8’.



PROGRAMMING

//Arduino Project - Color Sorting Machine
#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()
{
// connect to ‘D2’
pinMode(S0, OUTPUT);
pinMode(S1, OUTPUT);
//connect to ‘D3’
pinMode(S2, OUTPUT);
//connect to ‘D4’
pinMode(S3, OUTPUT);
//connect to ‘D5’
pinMode(sensorOut, INPUT);
// Setting frequency-scaling to 20%
digitalWrite(S0, HIGH);
digitalWrite(S1, LOW);
//function for the top motor
topServo.attach(7);
//function for the bottom motor
bottomServo.attach(8);
Serial.begin(9600);
}

//loop for the top motor.
void loop() {
topServo.write(115);
delay(500);
for (int i = 115; i > 65; i--) {
topServo.write(i);
delay(2);
}
delay(500);
color = readColor();
delay(10);
//For the bottom motor to move my some degree
switch (color) {
//bottom motor move by an angle 50 on RED
case 1: bottomServo.write(50);
break;
//bottom motor move by an angle 75 on GREEN
case 2: bottomServo.write(75);
break;
case 0: break;
}
delay(300);
for (int i = 65; i > 29; i--) {
topServo.write(i);
delay(2);
}
delay(200);
for (int i = 29; i < 115; i++) {
topServo.write(i);
delay(2);
}
color = 0;
}

// Custom Function - readColor()
int readColor() {
// Setting red filtered photodiodes to be read
digitalWrite(S2, LOW);
digitalWrite(S3, LOW);
// Reading the output frequency
frequency = pulseIn(sensorOut, LOW);
int R = frequency;
// Printing the value on the serial monitor
Serial.print("R= "); //printing name
Serial.print(frequency); //printing RED color frequency
Serial.print(" ");
delay(50);
// Setting Green filtered photodiodes to be read
digitalWrite(S2, HIGH);
digitalWrite(S3, HIGH);
// Reading the output frequency
frequency = pulseIn(sensorOut, LOW);
int G = frequency;
// Printing the value on the serial monitor
Serial.print("G= "); //printing name
//printing RED color frequency#include <Servo.h>
Serial.print(frequency);
#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); // connect to ‘D2’
pinMode(S1, OUTPUT);
//connect to ‘D3’
pinMode(S2, OUTPUT);
//connect to ‘D4’
pinMode(S3, OUTPUT);
//connect to ‘D5’
pinMode(sensorOut, INPUT);
// Setting frequency-scaling to 20%
digitalWrite(S0, HIGH);
digitalWrite(S1, LOW);
topServo.attach(7); //function for the top motor
bottomServo.attach(8); //function for the bottom motor
Serial.begin(9600);
}

void loop() //loop for the top motor. {
topServo.write(115);
delay(500);
for (int i = 115; i > 65; i--) {
topServo.write(i);
delay(2);
}
delay(500);
color = readColor();
delay(10);
//For the bottom motor to move my some degree
switch (color) {
//bottom motor move by an angle 50 on RED
case 1: bottomServo.write(50);
break;
//bottom motor move by an angle 75 on GREEN
case 2: bottomServo.write(75);
break;
case 0: break;
}
delay(300);
for (int i = 65; i > 29; i--) {
topServo.write(i);
delay(2);
}
delay(200);
for (int i = 29; i < 115; i++) {
topServo.write(i);
delay(2);
}
color = 0;
} // Custom Function - readColor()
int readColor() {
// Setting red filtered photodiodes to be read
digitalWrite(S2, LOW);
digitalWrite(S3, LOW);
// Reading the output frequency
frequency = pulseIn(sensorOut, LOW);
int R = frequency;
// Printing the value on the serial monitor
Serial.print("R= "); //printing name
Serial.print(frequency); //printing RED color frequency
Serial.print(" ");
delay(50);
// Setting Green filtered photodiodes to be read
digitalWrite(S2, HIGH);
digitalWrite(S3, HIGH);
// Reading the output frequency
frequency = pulseIn(sensorOut, LOW);
int G = frequency;
// Printing the value on the serial monitor
Serial.print("G= "); //printing name
Serial.print(frequency);
//printing RED color frequency#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); // connect to ‘D2’
pinMode(S1, OUTPUT);
//connect to ‘D3’
pinMode(S2, OUTPUT);
//connect to ‘D4’
pinMode(S3, OUTPUT);
//connect to ‘D5’
pinMode(sensorOut, INPUT);
// Setting frequency-scaling to 20%
digitalWrite(S0, HIGH);
digitalWrite(S1, LOW);
topServo.attach(7); //function for the top motor
bottomServo.attach(8); //function for the bottom motor
Serial.begin(9600);
}

void loop() //loop for the top motor. {
topServo.write(115);
delay(500);

for (int i = 115; i > 65; i--){
topServo.write(i);
delay(2);
}
delay(500);
color = readColor();
delay(10);
//For the bottom motor to move my some degree
switch (color) {
case 1:bottomServo.write(50); //bottom motor move by an angle 50 on RED
break;
case 2: bottomServo.write(75);
//bottom motor move by an angle 75 on GREEN
break;

case 0: break;
}
delay(300);
for (int i = 65; i > 29; i--) {
topServo.write(i);
delay(2);
}
delay(200);

for (int i = 29; i < 115; i++) {
topServo.write(i);
delay(2);
}
color = 0;
} // Custom Function - readColor()

int readColor() {
// Setting red filtered photodiodes to be read
digitalWrite(S2, LOW);
digitalWrite(S3, LOW);
// Reading the output frequency
frequency = pulseIn(sensorOut, LOW);
int R = frequency;
// Printing the value on the serial monitor
Serial.print("R= "); //printing name
Serial.print(frequency); //printing RED color frequency
Serial.print(" ");
delay(50);
// Setting Green filtered photodiodes to be read
digitalWrite(S2, HIGH);
digitalWrite(S3, HIGH);
// Reading the output frequency
frequency = pulseIn(sensorOut, LOW);
int G = frequency;
// Printing the value on the serial monitor
Serial.print("G= "); //printing name
Serial.print(frequency); //printing RED color frequency
Serial.print(" ");
delay(50);
// Setting Blue filtered photodiodes to be read
digitalWrite(S2, LOW);
digitalWrite(S3, HIGH);
// Reading the output frequency
frequency = pulseIn(sensorOut, LOW);
int B = frequency;
// Printing the value on the serial monitor
Serial.print("B= "); //printing name
Serial.print(frequency); //printing RED color frequency
Serial.println(" ");
delay(50);
if (R<45 & R> 32 & G<65 & G> 55) {
color = 1; // Red
}
if (G<55 & G> 43 & B<47 & B> 35) {
color = 2; // Green
}
return color;
}
}
}

TESTING: -


Initially we have to check the ​R​G​B​of a particular color

accordingly we’ve to give the color
sequence in line no. (94 and 97).
So, let we have taken first ​RED ​color ball so the bottom
motor will move by 50 degrees and if we put ​GREEN​color
ball the motor will move by 75 degrees.

Let’s understand it clearly through a short video
demonstration in order to clear your all doubts.

VIDEO DEMONSTRATION: -


CONTACT DETAILS: -

Gautam Gupta (Founder)

Mob.no-7979986934



Team Members: -
Keshav Pratap Singh







Md Saquib Siddiqui






Md Waquas





Md Shahnawaz Khan








Comments

Popular posts from this blog

SAMPLE PROJECT

LET'S KNOW GINNOVATION