Arduino Sketch for Plastic Bottle and Can Reverse Vending Machine

 

This Reverse Vending Machine (RVM) project automatically identifies, segregates, and records plastic bottles and aluminum cans. It uses multiple sensors for detection and verification, servo motors for sorting, and wireless communication (GSM/WiFi) for data reporting.


 Project Overview

The system integrates:

  • Arduino UNO – Main controller

  • Ultrasonic Sensors (HC-SR04) – Object distance & insertion detection

  • Load Cell with HX711 module – Weight verification

  • Inductive Sensor – Metal can detection

  • Photoelectric Sensor – Object presence detection

  • Micro Servo Motors (SG90/MG90S) – Sorting gate control

  • GSM Module (SIM800/SIM900) – SMS/data communication

  • WiFi Module (ESP8266) – Cloud data transmission

  • 16x2 LCD Display – User interface

  • Relay/Driver Circuits – Actuator control


 Working Principle

  1. Object Insertion Detection

    • Photoelectric sensor detects item entry.

    • Ultrasonic sensor confirms object position.

  2. Material Identification

    • Inductive sensor detects metal (aluminum cans).

    • If not metal, the system checks weight using load cell to confirm plastic bottle.

  3. Sorting Mechanism

    • Servo motor rotates gate:

      • Metal → Can compartment

      • Plastic → Bottle compartment

  4. Weight Recording

    • Load cell measures item weight.

    • Data logged for reward calculation.

  5. Data Communication

    • Sends transaction data via GSM SMS or WiFi to cloud/server.

    • Tracks total items collected.

  6. User Interface

    • LCD displays:

      • “Insert Item”

      • Item Type (Can/Bottle)

      • Weight

      • Points Earned

      • Thank You Message


Key Features

  • Automatic plastic and metal segregation

  • Accurate weight-based validation

  • Dual communication (GSM + WiFi)

  • Real-time LCD feedback

  • Smart recycling reward-ready system

  • Scalable for public recycling stations


Code:

/*
 * Arduino Sketch for Plastic Bottle and Can Reverse Vending Machine
 * This code interfaces with various sensors and actuators to segregate
 * plastic bottles and cans, and provides WiFi access for data transmission.
 * Components used:
 * - Ultrasonic Sensors for distance measurement
 * - Load Cell for weight measurement
 * - Micro Servos for actuation
 * - GSM Module for communication
 * - LCD Display for user interface
 * - Inductive and Photoelectric Sensors for object detection
 */

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

// Pin definitions
#define TRIG_PIN1 5
#define ECHO_PIN1 6
#define TRIG_PIN2 7
#define ECHO_PIN2 8
#define SERVO_PIN1 9
#define SERVO_PIN2 10
#define SERVO_PIN3 11
#define SERVO_PIN4 12
#define LOAD_CELL_DOUT_PIN 13
#define LOAD_CELL_SCK_PIN 14
#define INDUCTIVE_SENSOR_PIN 2
#define PHOTOELECTRIC_SENSOR_PIN 16
#define GSM_TX_PIN 3
#define GSM_RX_PIN 18
#define LCD_RS_PIN 17
#define LCD_E_PIN 18
#define LCD_DB4_PIN 19
#define LCD_DB5_PIN 20
#define LCD_DB6_PIN 21
#define LCD_DB7_PIN 22

// Servo objects
Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;

// Load Cell object
HX711 scale;

// LCD object
LiquidCrystal lcd(LCD_RS_PIN, LCD_E_PIN, LCD_DB4_PIN, LCD_DB5_PIN, LCD_DB6_PIN, LCD_DB7_PIN);

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

  // Initialize ultrasonic sensors
  pinMode(TRIG_PIN1, OUTPUT);
  pinMode(ECHO_PIN1, INPUT);
  pinMode(TRIG_PIN2, OUTPUT);
  pinMode(ECHO_PIN2, INPUT);

  // Initialize servos
  servo1.attach(SERVO_PIN1);
  servo2.attach(SERVO_PIN2);
  servo3.attach(SERVO_PIN3);
  servo4.attach(SERVO_PIN4);

  // Initialize load cell
  scale.begin(LOAD_CELL_DOUT_PIN, LOAD_CELL_SCK_PIN);

  // Initialize LCD
  lcd.begin(16, 2);
  lcd.print("RVM System");

  // Initialize sensors
  pinMode(INDUCTIVE_SENSOR_PIN, INPUT);
  pinMode(PHOTOELECTRIC_SENSOR_PIN, INPUT);
}

void loop() {
  // Measure distance with ultrasonic sensor 1
  long duration1, distance1;
  digitalWrite(TRIG_PIN1, LOW);
  delayMicroseconds(2);
  digitalWrite(TRIG_PIN1, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG_PIN1, LOW);
  duration1 = pulseIn(ECHO_PIN1, HIGH);
  distance1 = (duration1 / 2) / 29.1;

  // Measure distance with ultrasonic sensor 2
  long duration2, distance2;
  digitalWrite(TRIG_PIN2, LOW);
  delayMicroseconds(2);
  digitalWrite(TRIG_PIN2, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG_PIN2, LOW);
  duration2 = pulseIn(ECHO_PIN2, HIGH);
  distance2 = (duration2 / 2) / 29.1;

  // Read load cell value
  float weight = scale.get_units(10);

  // Read inductive sensor value
  int inductiveValue = digitalRead(INDUCTIVE_SENSOR_PIN);

  // Read photoelectric sensor value
  int photoelectricValue = digitalRead(PHOTOELECTRIC_SENSOR_PIN);

  // Display values on LCD
  lcd.setCursor(0, 1);
  lcd.print("Dist1:");
  lcd.print(distance1);
  lcd.print("cm ");
  lcd.print("Dist2:");
  lcd.print(distance2);
  lcd.print("cm");

  // Actuate servos based on sensor values
  if (inductiveValue == HIGH) {
    servo1.write(90);
  } else {
    servo1.write(0);
  }

  if (photoelectricValue == HIGH) {
    servo2.write(90);
  } else {
    servo2.write(0);
  }

  if (weight > 100) {
    servo3.write(90);
  } else {
    servo3.write(0);
  }

  delay(1000);
}

Applications

  • Smart recycling stations

  • IoT-based waste management systems

  • College & public recycling projects

  • Smart city initiatives

  • Environmental sustainability automation

 

IOT & SMART SYSTEM PROJECTS

  1. IoT Weather Monitoring System (NodeMCU ESP8266 + DHT11 + Rain Sensor)
  2. ESP8266 NodeMCU Smart Health & Environment Monitoring System with Pulse, Temperature and Motion Sensors
  3. ESP32 Wi-Fi Weight Sensor with HX711
  4. Smart RFID Access Control System Using ESP32 Dev Board and UHF RFID Reader Module
  5. Smart IoT Motor Control System Using ESP32 Dev Board and L298N Motor Driver Module
  6. Smart Waste Management System Using Arduino Nano, Ultrasonic Sensor & GSM Module – Solar Powered IoT Solution
  7. Raspberry Pi Zero W and GSM SIM900 Based Ultrasonic Distance Measurement System
  8. Arduino UNO Smart Surveillance System with ESP8266 WiFi, PIR Motion Sensor & Camera Module
  9. Arduino UNO Environmental Monitoring System with OLED & 16x2 I2C LCD Display
  10. Arduino UNO-Based Smart Home Automation System with Flame and IR Sensors 
  11. Arduino Nano-Based Landslide Detection System with GSM Alerts – Smart Disaster Monitoring Project
  12. Arduino Nano Rain-Sensing Stepper Motor System
  13. Arduino Based Automatic Tire Inflator Using Pressure Sensor, Relay Module and LCD Display
  14. Arduino-Based Automatic Cooker Using Servo Motors, DC Stirrer Motor, Temperature Sensor and Relay-Controlled Heater
  15. Arduino Sketch for Plastic Bottle and Can Reverse Vending Machine

 TRAFFIC & SMART CITY PROJECTS
  1. RFID-Based Smart Traffic Control System (Arduino Mega)
  2. Arduino UNO Traffic Light Control System – Smart LED Signal Project
  3.  Arduino UNO Controlled Traffic Light System with Joystick Interface

ROBOTICS PROJECTS
  1. Arduino UNO Smart Obstacle Avoiding Robot (Ultrasonic + IR + GSM)
  2. Arduino-Powered Autonomous Obstacle Avoidance Robot with Servo Control
  3. Arduino Nano Bluetooth Controlled Line Follower Robot Using L298N Motor Driver
  4. Arduino UNO Bluetooth Controlled 4WD Robot Car Using L298N Motor Driver
  5. Arduino UNO Multi-Sensor Obstacle Avoidance & Bluetooth Controlled Robot Car Using L298N
  6. Raspberry Pi Motor Control Robot (L298N + Li-ion)
  7. RC Car Simulation with L298N Motor Driver and Joystick Control using Arduino (CirkitDesign Simulation)
  8. Raspberry Pi Robotic Arm Control System with Camera Module and Motor Driver – Smart Automation & Vision-Based Robotics Project
  9. ESP32-Based 4WD Robot Car Using Dual L298N Motor Drivers – Circuit Diagram and IoT Control Project

LORA & WIRELESS COMMUNICATION PROJECTS
  1. Arduino LoRa Communication Project Using Adafruit RFM95W LoRa RadioArduino Nano with RFM95 SX1276 LoRa
  2. Arduino Nano with RFM95 LoRa SX1276 Module – Long Range Wireless Communication Project
  3. Arduino Nano Digital Clock Using DS3231 RTC and TM1637 4-Digit Display – Circuit Diagram and Project Guide

 LED, LIGHTING & DISPLAY PROJECTS
  1. Arduino UNO Controlled NeoPixel Ring Light Show
  2. Wi-Fi Controlled NeoPixel Ring (ESP8266)
  3. Chained NeoPixel Rings with Arduino – Addressable RGB LED Control Project
  4. Arduino Nano-Controlled Lighting System with Gesture and Sound Interaction
  5. Raspberry Pi GPIO Multi-LED Control System – Beginner-Friendly Embedded Electronics Project
  6. 4 Channel Relay Module with Arduino UNO

 SENSOR & DETECTION PROJECTS
  1. Arduino UNO Color Sensor + Proximity System (TCS3200 + Inductive)
  2. Arduino Color Detection Project Using Adafruit TCS34725 RGB Color Sensor
  3. Arduino Gas Leakage Detection and Safety Alert System Using MQ-2 Gas Sensor
  4. MQ-135 Air Quality Detector Using Arduino | Cirkit Designer Simulation Project
  5. Pulse Sensor Using Arduino – Complete Guide with Simulation 
  6. HX711 Load Sensor Demo Using Arduino | Digital Weight Measurement Project
  7. Track Time with DS1307 RTC and Display on Arduino Uno with 16x2 LCD | Cirkit Designer Project
  8. Parking Sensor Simulator using Arduino Uno and HC-SR04 Ultrasonic Sensor

 FUN & INTERACTIVE PROJECTS
  1. Pong Game with Arduino UNO and OLED Display – Project Explanation
  2.   Arduino UNO Bluetooth-Controlled Servo Motor System
  3. Arduino UNO-Based Interactive Touch and Distance Sensing System with LED Indicators and Servo Control

 INDUSTRIAL / AUTOMATION PROJECTS
  1. Arduino UNO Smart Waste Sorting System Using Ultrasonic Sensor, Moisture Sensor, Servo, Stepper Motor and LCD
  2. Arduino-Based Smart Waste Segregation System Using Metal, Plastic and Moisture Sensors with Stepper and Servo Control
  3. ESP32-Based Digital Weighing Scale Using 50kg Load Cell, HX711 Module and 16x2 LCD Display
  4. Arduino-Based Smart Toll Gate Automation System with RFID, GSM, Ultrasonic Sensor and LCD Display

  5. Arduino-Based Automatic Pill Dispenser Machine with LCD Display, Servo Motor and Buzzer Reminder

  6. Arduino UNO Smart Water Quality Monitoring System with pH Sensor, Turbidity Sensor and LCD Display

  7. Arduino-Based Ocean Cleaning Boat Robot with Dual IBT-2 Motor Drivers and Conveyor Belt System

  8. IoT-Based Accident Detection and Health Monitoring System Using Raspberry Pi with GSM, GPS and Camera Integration

  9. Raspberry Pi RFID and Keypad Based Smart Door Lock System with LCD Display and L298N Motor Driver

  10. Smart Shopping Trolley Using Arduino UNO & RFID | Automatic Billing System

  11. Arduino UNO Based Automatic Liquid Hand Sanitizer & Soap Dispenser System

  12. Arduino Based Robotic Weeding Machine with Ultrasonic Obstacle Detection and L298N Motor Driver

  13. Arduino UNO Based Biometric Electronic Voting System with LCD Display and Fingerprint Authentication

  14. Arduino UNO Based Electronic Voting System with ILI9341 TFT Display

Comments