Smart waste segregation system

Automated waste segregation using Arduino, sensors, and servo motors to sort wet/dry waste, reduce labor, and improve urban sanitation.

IntermediateWork in progress12 hours82
Smart waste segregation system

Things used in this project

Story

Read more

Code

Untitled file

C/C++
#include <Servo.h>

Servo servo1; // Servo to control flap/lid

#define ir 5
#define buzzer 12
#define potPin A0 // Soil moisture analog input

int soil = 0;
int fsoil = 0;

void setup() {
  Serial.begin(9600);
  
  pinMode(ir, INPUT);
  pinMode(buzzer, OUTPUT);
  
  servo1.attach(7); // Connect servo signal pin to D7
  servo1.write(90); // Neutral (closed flap)
  delay(1000);
}

void loop() {
  fsoil = 0;

  if (digitalRead(ir) == 0) {
    tone(buzzer, 1000, 300);
    delay(300);

    // Read and average soil moisture
    for (int i = 0; i < 3; i++) {
      soil = analogRead(potPin);
      Serial.print("Raw soil reading: ");
      Serial.println(soil);
      fsoil += soil;
      delay(75);
    }

    fsoil = fsoil / 3;
    Serial.print("Average moisture reading: ");
    Serial.println(fsoil);

    if (fsoil < 500) {
      Serial.println("Wet waste detected → rotating to 30°");
      servo1.write(30);   // Wet side
    } else {
      Serial.println("Dry waste detected → rotating to 150°");
      servo1.write(150);  // Dry side
    }

    delay(1000);
    Serial.println("Returning to center (90°)");
    servo1.write(90); // Back to center
    delay(1000);
  }
}

Credits

SREERAJ K N
1 project • 2 followers
Sivapriya Ashok
1 project • 2 followers
Nihal Nasar
1 project • 3 followers
MALAVIKA SHAJI
1 project • 2 followers

Comments