Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO-Based Smart Sorting System with Servo and Stepper Motors

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Smart Sorting System with Servo and Stepper Motors

Circuit Documentation

Summary

This circuit is designed to detect different types of materials (wet, metal, and plastic) using various sensors. Based on the detected material, it rotates a compartment using a stepper motor to place the material in the designated compartment. A servo motor is used to control a gate mechanism to drop the material.

Component List

  1. Arduino UNO

    • Description: 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
  2. MB102 Breadboard Power Supply Module 3.3V/5V

    • Description: Power supply module that provides 3.3V and 5V outputs.
    • Pins: VCC, GND, 3.3V, 5V
  3. Micro servo 9G

    • Description: Small servo motor used for precise control of angular position.
    • Pins: GND, +5V, PWM
  4. RAIN SENSOR

    • Description: Sensor used to detect the presence of water.
    • Pins: AO, DO, GRD, VCC
  5. 28BYJ-48 Stepper Motor

    • Description: Stepper motor used for precise control of rotational position.
    • Pins: BLUE, PINK, YELLOW, ORANGE, RED
  6. ULN2003A breakout board

    • Description: Driver board for controlling the 28BYJ-48 stepper motor.
    • Pins: In 1, In 2, In 3, In 4, In 5, In 6, In 7, 0V, +5V, ON/OFF jumper switch, BLUE wire, PINK wire, YELLOW wire, ORANGE wire, RED wire
  7. LJ18A3-H-ZBX Inductive Proximity Sensor

    • Description: Sensor used to detect metal objects.
    • Pins: VO (BLU), VI (BRN), SIG (BLK)
  8. 9V Battery

    • Description: Power source for the circuit.
    • Pins: -, +
  9. IR Sensor

    • Description: Sensor used to detect objects using infrared light.
    • Pins: out, gnd, vcc

Wiring Details

Arduino UNO

MB102 Breadboard Power Supply Module 3.3V/5V

Micro servo 9G

RAIN SENSOR

28BYJ-48 Stepper Motor

ULN2003A breakout board

LJ18A3-H-ZBX Inductive Proximity Sensor

9V Battery

IR Sensor

Code Documentation

/*
 * This Arduino sketch reads from three sensors to detect metal, plastic, and wet
 * materials. Based on the detected material, it rotates a compartment using a
 * stepper motor to place the material in the designated compartment. A servo
 * motor is used to control a gate mechanism to drop the material.
 */

#include <Servo.h>
#include <Stepper.h>

// Pin definitions
const int rainSensorPin = A0;
const int proximitySensorPin = 2;
const int servoPin = 3;
const int stepperIn1 = 8;
const int stepperIn2 = 9;
const int stepperIn3 = 10;
const int stepperIn4 = 11;

// Stepper motor setup
const int stepsPerRevolution = 2048;
Stepper myStepper(stepsPerRevolution, stepperIn1, stepperIn3, stepperIn2, stepperIn4);

// Servo motor setup
Servo myServo;

void setup() {
  // Initialize serial communication
  Serial.begin(9600);

  // Initialize sensors
  pinMode(rainSensorPin, INPUT);
  pinMode(proximitySensorPin, INPUT);

  // Initialize servo motor
  myServo.attach(servoPin);
  myServo.write(0); // Initial position

  // Initialize stepper motor
  myStepper.setSpeed(10); // Set speed to 10 RPM
}

void loop() {
  // Read sensor values
  int rainValue = analogRead(rainSensorPin);
  int proximityValue = digitalRead(proximitySensorPin);

  // Determine material type
  if (rainValue > 500) { // Wet material detected
    Serial.println("Wet material detected");
    rotateCompartment(0); // Rotate to wet compartment
  } else if (proximityValue == HIGH) { // Metal detected
    Serial.println("Metal detected");
    rotateCompartment(1); // Rotate to metal compartment
  } else { // Assume plastic if no other material detected
    Serial.println("Plastic detected");
    rotateCompartment(2); // Rotate to plastic compartment
  }

  // Drop material
  dropMaterial();

  // Wait before next detection
  delay(2000);
}

void rotateCompartment(int compartment) {
  // Rotate stepper motor to the correct compartment
  int steps = compartment * (stepsPerRevolution / 3); // Assuming 3 compartments
  myStepper.step(steps);
}

void dropMaterial() {
  // Use servo to drop material
  myServo.write(90); // Open gate
  delay(1000); // Wait for material to drop
  myServo.write(0); // Close gate
}

This code reads sensor values to detect the type of material and then uses a stepper motor to rotate to the appropriate compartment. A servo motor is used to open and close a gate to drop the material into the compartment.