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

Arduino Nano-Controlled Smart Waste Sorting Bin with Servos and Sensors

View and Edit Project In Cirkit DesignerImage of Arduino Nano-Controlled Smart Waste Sorting Bin with Servos and Sensors

Smart Bin Circuit Documentation

Summary

The Smart Bin Circuit is designed to automate the process of sorting metal and non-metal waste using an array of sensors, servo motors, and a display unit. The system is controlled by an Arduino Nano microcontroller, which processes inputs from metal detection and infrared sensors to actuate two servo motors that direct waste into the appropriate bins. The circuit also includes a 0.96" OLED display to provide visual feedback and status information.

Component List

9V Battery

Servo Motors

Arduino Nano

Metal Detection Sensor

IR Sensors

0.96" OLED Display

Comments

Wiring Details

9V Battery

Servo Motors

Arduino Nano

Metal Detection Sensor

IR Sensors

0.96" OLED Display

Documented Code

Arduino Nano Code

#include <Servo.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h> 

const int nonmetalPin = D3;
const int tongsampah1 = D4;
const int tongsampah2 = D5;
#define metalsensor D2

#define OLED_ADDR   0x3C
#define OLED_RESET  -1
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET);

Servo myservo_nonmetal; // create servo object to control a servo on plastic bin
Servo myservo_metal; // create servo object to control a servo on metal bin

int nonmetal = 0; // default servo position of plastic bin
int metal = 0; // default servo position of metal bin

void setup() {
    Serial.begin(9600);
    myservo_nonmetal.attach(A6); // attaches the plastic bin servo on pin 6 to the servo object
    myservo_metal.attach(A7); // attaches the metal bin servo on pin 7 to the servo object
    pinMode(nonmetalPin, INPUT);
    pinMode(tongsampah1, INPUT);
    pinMode(tongsampah2, INPUT);
    pinMode(metalsensor, INPUT);
    if(!display.begin(OLED_ADDR, OLED_RESET)) {
        Serial.println(F("SSD1306 allocation failed"));
        for(;;);
    }
    display.display();
    delay(2000);
    display.clearDisplay();
    display.setTextSize(1);      // Normal 1:1 pixel scale
    display.setTextColor(SSD1306_WHITE); // Draw white text
    display.display();
}

void loop() {
    int sensor_read_nonmetal = digitalRead(nonmetalPin);
    int sensor_read_metal = digitalRead(metalsensor);
    int sensor_tongsampah1 = digitalRead(tongsampah1);
    int sensor_tongsampah2 = digitalRead(tongsampah2);

    Serial.println("nonmetal sensor");
    Serial.println(sensor_read_nonmetal);
    Serial.println("metal sensor");
    Serial.println(sensor_read_metal);
    Serial.println("tong sampah 1");
    Serial.println(sensor_tongsampah1);
    Serial.println("tong sampah 2");
    Serial.println(sensor_tongsampah2);

    display.setCursor(0, 0);     // Start at top-left corner
    display.println(F("----SMART BIN----"));
    display.display();

    if ((sensor_read_nonmetal == 1) && (sensor_read_metal != 1)) {
        display.setCursor(0, 10);
        display.print("Sampah non metal");
        myservo_nonmetal.write(90);
        delay(2500);
        myservo_nonmetal.write(0);
        delay(2500);
        if(sensor_tongsampah1 == 1){
            int jumlah_sampah = sensor_tongsampah1;
            jumlah_sampah++;
            display.setCursor(0, 20);
            display.print("jumlah_sampah");
            display.println(jumlah_sampah);
            display.display();
        }
    } else {
        // keep the door closed
        myservo_nonmetal.write(nonmetal);
    }

    if ((sensor_read_metal == 1) && (sensor_read_nonmetal != 1)) {
        display.setCursor(0, 30);
        display.print("Sampah metal");
        myservo_metal.write(90);
        delay(2500);
        myservo_metal.write(0);
        delay(2500);
        if(sensor_tongsampah2 == 1){
            int jumlah_sampah1 = sensor_tongsampah2;
            jumlah_sampah1++;
            display.setCursor(0, 40);
            display.print("jumlah_sampah");
            display.println(jumlah_sampah1);
            display.display();    
        }
    } else {
        // keep the door closed
        myservo_metal.write(metal);
    }
}

This code controls the Smart Bin's operation, including reading sensor inputs, actuating servo motors, and updating the OLED display with the status of the waste sorting process.