Arduino-Based Smart Waste Sorting System with Ultrasonic, Rain, and Proximity Sensors
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to detect and classify objects based on their material and moisture content. It uses an Arduino UNO microcontroller to interface with various sensors and actuators, including a rain sensor, ultrasonic sensor, capacitive proximity sensor, LCD display, servo motor, and stepper motor. The system can differentiate between metal, wet, and dry objects and sort them accordingly.
Component List
9V Battery
- Description: Provides power to the circuit.
- Pins: +, -
Arduino UNO
- Description: Microcontroller used to control the circuit.
- 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
RAIN SENSOR
- Description: Detects the presence of rain or moisture.
- Pins: AO, DO, GRD, VCC
Lcd 20x4 i2c
- Description: Displays information to the user.
- Pins: GND, 5v, SCA, SCL
HC-SR04 Ultrasonic Sensor
- Description: Measures distance to an object.
- Pins: VCC, TRIG, ECHO, GND
LJC18A3-B-Z/BY Capacitive Proximity Sensor
- Description: Detects the presence of metal objects.
- Pins: VO (BLU), VI (BRN), SIG (BLK)
Micro servo 9G
- Description: Actuator used to move objects.
- Pins: GND, +5V, PWM
28BYJ-48 Stepper Motor
- Description: Motor used to rotate objects to different positions.
- Pins: BLUE, PINK, YELLOW, ORANGE, RED
ULN 2003
- Description: Driver for the stepper motor.
- Pins: IN1, IN2, IN3, IN4, IN5, IN6, IN7, GND, +, COIL1, COIL2, COIL3, COIL4, COIL5
Wiring Details
9V Battery
+ connected to:
- ULN 2003 (+)
- Arduino UNO (5V)
- Lcd 20x4 i2c (5v)
- HC-SR04 Ultrasonic Sensor (VCC)
- LJC18A3-B-Z/BY Capacitive Proximity Sensor (VI (BRN))
- Micro servo 9G (+5V)
- connected to:
- Arduino UNO (GND)
- RAIN SENSOR (GRD)
- Lcd 20x4 i2c (GND)
- HC-SR04 Ultrasonic Sensor (GND)
- LJC18A3-B-Z/BY Capacitive Proximity Sensor (VO (BLU))
- Micro servo 9G (GND)
Arduino UNO
- 5V connected to 9V Battery (+)
- GND connected to 9V Battery (-) and ULN 2003 (GND)
- A0 connected to RAIN SENSOR (AO)
- A4 connected to Lcd 20x4 i2c (SCA)
- A5 connected to Lcd 20x4 i2c (SCL)
- D0 connected to RAIN SENSOR (DO)
- D2 connected to HC-SR04 Ultrasonic Sensor (ECHO)
- D3 connected to HC-SR04 Ultrasonic Sensor (TRIG)
- D6 connected to RAIN SENSOR (VCC)
- D7 connected to LJC18A3-B-Z/BY Capacitive Proximity Sensor (SIG (BLK))
- D8 connected to ULN 2003 (IN1)
- D9 connected to ULN 2003 (IN2)
- D10 connected to ULN 2003 (IN3)
- D11 connected to ULN 2003 (IN4)
- D13 connected to Micro servo 9G (PWM)
RAIN SENSOR
- AO connected to Arduino UNO (A0)
- DO connected to Arduino UNO (D0)
- GRD connected to 9V Battery (-)
- VCC connected to Arduino UNO (D6)
Lcd 20x4 i2c
- GND connected to 9V Battery (-)
- 5v connected to 9V Battery (+)
- SCA connected to Arduino UNO (A4)
- SCL connected to Arduino UNO (A5)
HC-SR04 Ultrasonic Sensor
- VCC connected to 9V Battery (+)
- TRIG connected to Arduino UNO (D3)
- ECHO connected to Arduino UNO (D2)
- GND connected to 9V Battery (-)
LJC18A3-B-Z/BY Capacitive Proximity Sensor
- VO (BLU) connected to 9V Battery (-)
- VI (BRN) connected to 9V Battery (+)
- SIG (BLK) connected to Arduino UNO (D7)
Micro servo 9G
- GND connected to 9V Battery (-)
- +5V connected to 9V Battery (+)
- PWM connected to Arduino UNO (D13)
28BYJ-48 Stepper Motor
- BLUE connected to ULN 2003 (COIL1)
- PINK connected to ULN 2003 (COIL2)
- YELLOW connected to ULN 2003 (COIL3)
- ORANGE connected to ULN 2003 (COIL4)
- RED connected to ULN 2003 (COIL5)
ULN 2003
- + connected to 9V Battery (+)
- GND connected to Arduino UNO (GND)
- IN1 connected to Arduino UNO (D8)
- IN2 connected to Arduino UNO (D9)
- IN3 connected to Arduino UNO (D10)
- IN4 connected to Arduino UNO (D11)
- COIL1 connected to 28BYJ-48 Stepper Motor (BLUE)
- COIL2 connected to 28BYJ-48 Stepper Motor (PINK)
- COIL3 connected to 28BYJ-48 Stepper Motor (YELLOW)
- COIL4 connected to 28BYJ-48 Stepper Motor (ORANGE)
- COIL5 connected to 28BYJ-48 Stepper Motor (RED)
Documented Code
#include <Stepper.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
#define POWER_PIN 6 // The Arduino pin that provides the power to the rain sensor
#define DO_PIN 0 // The Arduino's pin connected to DO pin of the rain sensor
#define SERVO_PIN 13 // Pin for the servo motor
// Ultrasonic
const int trigPin = 3;
const int echoPin = 2;
long duration;
int distance;
// Inductive Sensor
const int InductiveSensor = 7;
// Stepper Motor
int stepsPerRevolution = 2048;
int rpm = 10;
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);
// Servo Motor
Servo myServo;
// LCD
LiquidCrystal_I2C lcd(0x27, 16, 2); // 16x2 LCD display
// Dry Object Detection Counter
int dryCounter = 0;
const int dryThreshold = 3; // Number of consecutive detections to confirm dry
// Stepper position tracker
int currentPosition = 0;
const int dryPosition = 0;
const int wetPosition = stepsPerRevolution / 3; // 120 degrees
const int metalPosition = stepsPerRevolution * 2 / 3; // 240 degrees
void setup() {
myStepper.setSpeed(rpm);
myServo.attach(SERVO_PIN); // Attach the Servo to pin 13
pinMode(InductiveSensor, INPUT);
pinMode(trigPin, OUTPUT); // Ultrasonic trig pin
pinMode(echoPin, INPUT); // Ultrasonic echo pin
pinMode(POWER_PIN, OUTPUT); // Rain sensor power pin
pinMode(DO_PIN, INPUT); // Rain sensor digital output pin
lcd.init(); // Initialize LCD
lcd.backlight(); // Turn on LCD backlight
Serial.begin(9600);
}
void loop() {
getDistance();
// Check for metal detection first
int inductiveValue = digitalRead(