Color shorting box with line fallowing robot


Color shorting box with line following robot

COLOR SHORTING ROBOT


Color sorting robots have become increasingly popular in recent years due to the growing demand for automation in various industries. Color sorting robots are used to separate and sort different colored objects based on their unique color characteristics. This can be a tedious and time-consuming task for human operators, making color-sorting robots a valuable tool for many businesses. In this article, we will explore how to build a color sorting box with a line following robot using Arduino.

Introduction to Color Sorting Boxes and Line Following Robots:-

A color sorting box is a device designed to sort objects based on their color. Color sorting boxes are commonly used in industries such as manufacturing, agriculture, and recycling, where there is a need to sort and separate objects based on their color. The line-following robot is a robot that is capable of following a pre-determined path by detecting and following a line.

Building a Color Sorting Box with a Line Following Robot using Arduino:-

Building a color sorting box with a line-following robot using Arduino is a relatively simple process, and it can be completed with just a few basic components. Here is a list of components you will need to build a basic color sorting box with a line the following the robot:

1. Arduino Uno board https://amzn.to/3lsbY95
2. Chassis https://amzn.to/3HOskQQ
3.RGB color sensor(TC34725) https://amzn.to/3xd5zRW
4. IR Module https://amzn.to/3XflmtW
5. Servo motor https://amzn.to/40WoTAu
6. AF Motor driver shield https://amzn.to/3ls9iZb
7. BO Motor & Wheel https://amzn.to/3HTpjyV
8.3.7v 2200 mAh Lithium battery https://amzn.to/3YCeGHk
9. Jumper wire https://amzn.to/40LMZ0r

Semantics diagram:-

SYMATICS DIAGRAM OF COLOR SHORTING ROBOT



Step 1: Connect the TC34725 RGB color sensor to the Arduino board

The TC34725 RGB color sensor is a device that can detect and measure the intensity of light in the red, green, and blue (RGB) color bands. It is a popular choice for color-sensing applications and is often used in combination with an Arduino board to control various devices or to monitor and display color data.

To connect the TC34725 RGB color sensor to the Arduino board, simply connect the SDA, SCL, and GND pins on the sensor to the corresponding SDA, SCL, and GND pins on the Arduino board. The VCC pin on the sensor should be connected to the 5V pin on the Arduino board.

The TC34725 RGB color sensor can be controlled using the Arduino programming language. To control the sensor, the user needs to install the Adafruit RGB Color Sensor Library, which can be found in the Arduino Library Manager. The library provides a simple interface for controlling the sensor, allowing the user to read the color data from the sensor with ease.

Step 2: Connect the line following sensor (IR Module) to the Arduino board

The line-following sensor is used to detect and follow a pre-determined path. To connect the 1st line following sensor (ir module) to the Arduino board, connect the signal pin (o/p) on their module to analog pin A2 on the Arduino board and the 2nd ir module of signal pin (o/p) is connected to analog pin A3 of Arduino and gnd to gnd and VCC to +5v of Arduino.

Step 3: Connect the servo motor to the Arduino board

The servo motor is used to control the movement of the color sorting box. To connect the servo motor to the Arduino board, connect the signal pin on the servo motor to the digital pin 10 on the Arduino board and gnd pin to gnd and vcc to +5v of Arduino.

Step 4: Connect the AF motor driver shield to the Arduino board

To connect the AF Motor Driver Shield to the Arduino Uno board, simply place the shield on top of the Arduino board and secure it in place with screws. The motors can then be connected to the motor driver shield by connecting the positive and negative leads of the motors to the appropriate motor connections on the shield.

Step 5: Write the code for the color sorting box with a line following robot

The final step in building a color sorting box with a line following robot using Arduino is to write the code for the robot. The code for the color sorting box with a line following robot can be written using the Arduino programming language, the Servo library, and the Line Following library. The code will control the RGB color sensor to detect and identify colors, the line-following sensor to follow the pre-determined path, and the servo motor and red, blue, and red color boxes to sort the objects based on their color.

Code:-

#include <Wire.h> #include "Adafruit_TCS34725.h" #include <Servo.h> #include <AFMotor.h> AF_DCMotor motor1(1); AF_DCMotor motor2(2); AF_DCMotor motor3(3); AF_DCMotor motor4(4); #define IR1 A3 #define IR2 A2 int var1; int var2; Servo myservo1; int color=0; unsigned char intersection = 0; Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_614MS, TCS34725_GAIN_1X); void setup() { Serial.begin(115200); myservo1.attach(10); pinMode(IR1,INPUT); pinMode(IR2,INPUT); myservo1.write(50); delay(2000); motor1.setSpeed(255); motor2.setSpeed(255); motor3.setSpeed(255); motor4.setSpeed(255); if (tcs.begin()) { Serial.println("Found sensor"); } else { Serial.println("No TCS34725 found ... check your connections"); while (1); } // Now we're ready to get readings! } void(* resetFunc) (void) = 0; void loop() { //Read_colour(); mission(); } void ir() { var1=analogRead(IR1); var2=analogRead(IR2); Serial.print("IR1="); Serial.print(var1); Serial.print(" "); Serial.print("IR2="); Serial.println(var2); } void Run() { ir(); if(var1>50 & var2>50) { Forward(); } if(var1>50 & var2<50) { TurnRight(); } if(var1<50 & var2>50) { TurnLeft(); } } int Read_colour() { uint16_t r, g, b, c, colorTemp, lux; tcs.getRawData(&r, &g, &b, &c); colorTemp = tcs.calculateColorTemperature(r, g, b); lux = tcs.calculateLux(r, g, b); Serial.print("Color Temp: "); Serial.print(colorTemp, DEC); Serial.print(" K - "); Serial.print("Lux: "); Serial.print(lux, DEC); Serial.print(" - "); Serial.print("R: "); Serial.print(r, DEC); Serial.print(" "); Serial.print("G: "); Serial.print(g, DEC); Serial.print(" "); Serial.print("B: "); Serial.print(b, DEC); Serial.print(" "); Serial.print("C: "); Serial.print(c, DEC); Serial.print(" "); Serial.println(" "); if(r<1900 & r>800 & g<810 & g>400){ Serial.println(" Red !\n"); color = 1; //Red } if(r<600 & r>250 & g<1100 & g>500 ){ Serial.println(" Green !\n"); color = 2; //Green } if(g<3000 & g>1200 & b<4000 & b>1500){ Serial.println(" Blue !\n"); color = 3; //Blue } return color; } void mission() { Run(); if(var1<50 & var2<50) { Stop(); color=Read_colour(); switch(color) { case 1: //Turn Left red(); break; case 2: //Turn Left green(); break; case 3: //Turn Right blue(); break; case 0: Stop(); break; } } } void red() { intersection++; if(intersection == 1) { Serial.print("Intersection="); Serial.println(intersection); myservo1.write(50); delay(2000); TurnBack(); } if(intersection == 2) { Serial.print("Intersection="); Serial.println(intersection); Forward(); delay(400); TurnRight(); delay(1600); Forward(); delay(500); } else if(intersection == 3) { Serial.print("Intersection="); Serial.println(intersection); Stop(); myservo1.write(90); delay(2000); myservo1.write(50);// for open the gripper delay(1000); motor1.run(BACKWARD); motor2.run(BACKWARD); motor3.run(FORWARD); motor4.run(FORWARD); delay(3000); Forward(); delay(400); } else if(intersection == 4) { Serial.print("Intersection="); Serial.println(intersection); Forward(); delay(400); TurnLeft(); delay(1600); Forward(); delay(400); } else if(intersection == 5) { Serial.print("Intersection="); Serial.println(intersection); resetFunc(); } } void green() { intersection++; if(intersection == 1) { Serial.print("Intersection="); Serial.println(intersection); myservo1.write(50); delay(2000); TurnBack(); } if(intersection == 2) { Serial.print("Intersection="); Serial.println(intersection); Forward(); delay(1000); } else if(intersection == 3) { Serial.print("Intersection="); Serial.println(intersection); Stop(); delay(1000); myservo1.write(90); delay(2000); myservo1.write(50);// for open the gripper delay(1300); TurnBack(); } else if(intersection == 4) { Serial.print("Intersection="); Serial.println(intersection); Forward(); delay(1000); } else if(intersection == 5) { Serial.print("Intersection="); Serial.println(intersection); resetFunc(); } } void blue() { intersection++; if(intersection == 1) { Serial.print("Intersection="); Serial.println(intersection); myservo1.write(50); delay(2000); TurnBack(); } if(intersection == 2) { Serial.print("Intersection="); Serial.println(intersection); Forward(); delay(300); TurnLeft(); delay(1800); Forward(); delay(400); } else if(intersection == 3) { Serial.print("Intersection="); Serial.println(intersection); Stop(); delay(1000); myservo1.write(90); delay(2000); myservo1.write(50);// for open the gripper delay(1000); TurnBack(); } else if(intersection == 4) { Serial.print("Intersection="); Serial.println(intersection); Forward(); delay(400); TurnRight(); delay(1600); Forward(); delay(400); } else if(intersection == 5) { Serial.print("Intersection="); Serial.println(intersection); resetFunc(); } } void Forward() { Serial.println("Farward"); motor1.run(FORWARD); motor2.run(FORWARD); motor3.run(FORWARD); motor4.run(FORWARD); } void Backward() { Serial.println("Backward"); motor1.run(BACKWARD); motor2.run(BACKWARD); motor3.run(BACKWARD); motor4.run(BACKWARD); } void TurnRight() { Serial.println("Turn right"); motor1.run(BACKWARD); motor2.run(BACKWARD); motor3.run(FORWARD); motor4.run(FORWARD); } void TurnLeft() { Serial.println("Turn left"); motor1.run(FORWARD); motor2.run(FORWARD); motor3.run(BACKWARD); motor4.run(BACKWARD); } void TurnLeft_back() { Serial.println("Turn left"); motor1.run(FORWARD); motor2.run(FORWARD); motor3.run(BACKWARD); motor4.run(BACKWARD); } void TurnBack() { Serial.println("TurnBack"); motor1.run(BACKWARD); motor2.run(BACKWARD); motor3.run(FORWARD); motor4.run(FORWARD); delay(3000); Forward(); delay(300); } void Stop() { Serial.println("Stop"); motor1.run(RELEASE); motor2.run(RELEASE); motor3.run(RELEASE); motor4.run(RELEASE); }

Post a Comment

0 Comments