Arduino UNO and TCS3200-Based Smart Waste Sorting System with Color Detection
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to detect the color of an object using a TCS3200 color sensor and an Arduino UNO microcontroller. Based on the detected color, the circuit controls a servo motor to sort the object into different compartments. The TCS3200 sensor outputs frequency signals corresponding to the color intensity, which are read by the Arduino. The Arduino then processes these signals and controls the servo motor accordingly.
Component List
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
TCS3200
- Description: A color sensor that can detect and measure the intensity of red, green, and blue light.
- Pins: GND, OUT, S2, S3, VCC, LED, S0, S1
Wiring Details
Arduino UNO
- 5V: Connected to VCC and LED of the TCS3200.
- GND: Connected to GND of the TCS3200.
- A0: Connected to OUT of the TCS3200.
- D2: Connected to S0 of the TCS3200.
- D3: Connected to S1 of the TCS3200.
- D4: Connected to S2 of the TCS3200.
- D5: Connected to S3 of the TCS3200.
TCS3200
- VCC: Connected to 5V of the Arduino UNO.
- LED: Connected to 5V of the Arduino UNO.
- GND: Connected to GND of the Arduino UNO.
- OUT: Connected to A0 of the Arduino UNO.
- S0: Connected to D2 of the Arduino UNO.
- S1: Connected to D3 of the Arduino UNO.
- S2: Connected to D4 of the Arduino UNO.
- S3: Connected to D5 of the Arduino UNO.
Code Documentation
// Définir les broches utilisées pour le TCS3200
#define S0 2
#define S1 3
#define S2 4
#define S3 5
#define OUT 6
#define LED 7 // LED pour éclairage
// Définir la broche du servo moteur
#include <Servo.h>
Servo myservo; // Crée un objet pour contrôler le servo
void setup() {
// Initialisation des broches pour le capteur
pinMode(S0, OUTPUT);
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
pinMode(LED, OUTPUT); // LED pour éclairer l'objet
pinMode(OUT, INPUT);
// Commencer la communication série pour afficher les résultats
Serial.begin(9600);
// Initialisation du servo
myservo.attach(9); // Broche D9 pour le servo
// Allumer la LED pour éclairer l'objet
digitalWrite(LED, HIGH); // Activer l'éclairage LED
}
void loop() {
// Sélection des filtres pour mesurer les couleurs
// Pour mesurer la couleur rouge
digitalWrite(S2, LOW);
digitalWrite(S3, LOW);
int redValue = pulseIn(OUT, HIGH); // Mesure du temps en HIGH sur la sortie
// Pour mesurer la couleur verte
digitalWrite(S2, HIGH);
digitalWrite(S3, HIGH);
int greenValue = pulseIn(OUT, HIGH);
// Pour mesurer la couleur bleue
digitalWrite(S2, LOW);
digitalWrite(S3, HIGH);
int blueValue = pulseIn(OUT, HIGH);
// Affichage des valeurs des couleurs sur le moniteur série
Serial.print("Rouge : ");
Serial.print(redValue);
Serial.print("\tVert : ");
Serial.print(greenValue);
Serial.print("\tBleu : ");
Serial.println(blueValue);
// Identification du type de déchet en fonction des couleurs
if (redValue > greenValue && redValue > blueValue) {
Serial.println("Déchet plastique détecté - Couleur : Rouge");
// Action : Ouvrir le compartiment plastique
myservo.write(0); // Position du servo pour le plastique
delay(1000); // Attendre que le compartiment s'ouvre
myservo.write(90); // Refermer après une seconde
} else if (greenValue > redValue && greenValue > blueValue) {
Serial.println("Déchet verre détecté - Couleur : Vert");
// Action : Ouvrir le compartiment verre
myservo.write(45); // Position du servo pour le verre
delay(1000);
myservo.write(90); // Refermer après une seconde
} else if (blueValue > redValue && blueValue > greenValue) {
Serial.println("Déchet papier détecté - Couleur : Bleu");
// Action : Ouvrir le compartiment papier
myservo.write(135); // Position du servo pour le papier
delay(1000);
myservo.write(90); // Refermer après une seconde
} else {
Serial.println("Autre déchet - Couleur indéterminée");
// Action : Refuser ou stocker dans un compartiment commun
myservo.write(180); // Position du servo pour déchets autres
delay(1000);
myservo.write(90); // Refermer après une seconde
}
delay(2000); // Attendre avant de mesurer à nouveau
}
This code initializes the TCS3200 color sensor and a servo motor. It reads the color values from the sensor and prints them to the serial monitor. Based on the color detected, it moves the servo motor to sort the object into different compartments.