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

Arduino-Based Metal Detection and Sorting System with LCD Display and Servo Motor

View and Edit Project In Cirkit DesignerImage of Arduino-Based Metal Detection and Sorting System with LCD Display and Servo Motor

Circuit Documentation

Summary

This circuit is designed to detect metal objects using an inductive proximity sensor and sort them using a micro servo motor. The system is controlled by an Arduino UNO microcontroller, which also interfaces with a 16x2 LCD to display status messages.

Component List

  1. 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
  2. Micro servo 9G

    • Description: A small servo motor used for precise control of angular position.
    • Pins: GND, +5V, PWM
  3. LJ18A3-H-ZBX Inductive Proximity Sensor

    • Description: A sensor used to detect metal objects without physical contact.
    • Pins: VO (BLU), VI (BRN), SIG (BLK)
  4. 16X2 LCD

    • Description: A 16x2 character LCD display used to show status messages.
    • Pins: VSS, VDD, V0, RS, RW, E, D1, D0, D2, D3, D4, D6, D5, D7, A, K

Wiring Details

Arduino UNO

Micro servo 9G

LJ18A3-H-ZBX Inductive Proximity Sensor

16X2 LCD

Documented Code

#include <Servo.h>
#include <LiquidCrystal.h>

// Pin Definitions
const int sensorPin = 7;  // Proximity sensor input pin
const int servoPin = 9;   // Servo motor control pin
Servo metalServo;         // Servo motor object for sorting

// LCD Setup (using 4-bit mode)
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// Variables
int sensorState = 0;  // Variable to store the state of the sensor

void setup() {
  // Initialize sensor input pin
  pinMode(sensorPin, INPUT);
  
  // Initialize servo motor on pin 9
  metalServo.attach(servoPin);
  metalServo.write(0);  // Start servo in the initial position (0 degrees)
  
  // LCD initialization
  lcd.begin(16, 2);  // Initialize 16x2 LCD
  lcd.print("Waiting for metal...");
  
  delay(1000);
}

void loop() {
  // Read the state of the proximity sensor
  sensorState = digitalRead(sensorPin);
  
  if (sensorState == HIGH) {  // Metal detected
    lcd.clear();
    lcd.print("Metal detected!");
    
    // Move the servo to sort the metal waste
    metalServo.write(90);  // Move the servo to 90 degrees (separate metal)
    delay(2000);            // Wait for 2 seconds to allow sorting
    
    // Return the servo to initial position
    metalServo.write(0);
    
    // Display status on LCD
    lcd.clear();
    lcd.print("Waiting for metal...");
  } else {
    // If no metal detected, show this on LCD
    lcd.clear();
    lcd.print("Waiting for metal...");
    
    // Keep servo at initial position
    metalServo.write(0);
  }

  delay(500);  // Short delay to avoid multiple reads
}

This code initializes the proximity sensor, servo motor, and LCD display. It continuously checks the state of the proximity sensor and, upon detecting metal, moves the servo motor to sort the metal object and updates the LCD display accordingly.