Waste Segregator!
A small working project based on ARDUINO which separates Magnetic, Wet and Dry Wastes using few sensors and motors.
Components and supplies
1
SG90 Micro-servo motor
1
Arduino UNO
1
Alphanumeric LCD, 16 x 2
2
Ultrasonic Sensor - HC-SR04 (Generic)
1
Breadboard (generic)
1
Jumper wires (generic)
1
SparkFun Soil Moisture Sensor (with Screw Terminals)
2
DC Motor, 12 V
Tools and machines
1
Magnet, Button
1
Hot glue gun (generic)
Apps and platforms
1
Arduino IDE
Project description
Code
Code
arduino
1#include <Servo.h> 2#include <LiquidCrystal.h> 3Servo myservo; 4int pos = 0; 5const int trigPin1 = 9; 6const int echoPin1 = 8; 7const int trigPin2 = 7; 8const int echoPin2 = 6; 9const int led = 13; 10int sensorPin = A0; 11int sensorValue; 12int limit = 950; 13const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; 14LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 15float moisture; 16bool wet = false, obs2 = false; 17 18void setup() 19{ 20 lcd.begin(16, 2); 21 lcd.print("Waste Segregator"); 22 myservo.attach(10); 23 pinMode(trigPin1, OUTPUT); 24 pinMode(echoPin1, INPUT); 25 pinMode(trigPin2, OUTPUT); 26 pinMode(echoPin2, INPUT); 27 pinMode(led, OUTPUT); 28 myservo.write(pos); 29} 30 31// UV Obstacle Sensing Function 32bool obstacle(int trigPin, int echoPin, String s1){ 33 34 //for(int i=0;i<5;i++){ 35 //UV code 36 long duration, distance; 37 digitalWrite(trigPin, HIGH); 38 delayMicroseconds(1000); 39 digitalWrite(trigPin, LOW); 40 duration = pulseIn(echoPin, HIGH); 41 distance = (duration/2) / 29.1; 42 Serial.print(distance); 43 Serial.println("CM"+s1); 44 delay(10); 45 46 if(distance<=12) return true; 47 else return false; 48 //} 49 50} 51 52// Soil Moisture Sensor Code 53bool wetSense(){ 54 55 for(int i = 0; i < 8 ; i++) { 56 sensorValue = analogRead(sensorPin); 57 moisture = (100 - (sensorValue/1023.0)*100); 58 Serial.println("Analog Value : "); 59 Serial.println(sensorValue); 60 Serial.println("Moisture : "); 61 Serial.print(moisture); 62 Serial.println("%"); 63 if(sensorValue < limit){ 64 return true; 65 } 66 delay(500); 67 } 68 return false; 69} 70 71//LCD Display 72 73void printer(String s){ 74 75 lcd.setCursor(0, 1); 76 lcd.print(s); 77 delay(2000); 78 79} 80 81void loop() 82{ 83 Serial.begin(9600); 84 printer(" Monitoring... "); 85 if(obstacle(trigPin1, echoPin1,"one") == true){ 86 87 delay(11500); 88 for(int i = 0 ; i < 5 ; i++ ) { 89 obs2 = obstacle(trigPin2, echoPin2,"two"); 90 delay(200); 91 if(obs2 == true) { 92 delay(5300); 93 wet = (wetSense()); 94 break; 95 } 96 } 97 98 if(obs2==true && wet==true){ 99 100 myservo.write(pos+190); 101 printer(" Wet Waste "); 102 } 103 else if(obs2==true && wet==false){ 104 myservo.write(pos); 105 printer(" Dry Waste "); 106 myservo.write(pos); 107 } 108 else if(obs2==false) 109 printer(" Magnetic Waste "); 110 111 delay(2000); 112 } 113 delay(1000); 114
Code
arduino
1#include <Servo.h> 2#include <LiquidCrystal.h> 3Servo myservo; 4int pos = 0; 5const int trigPin1 = 9; 6const int echoPin1 = 8; 7const int trigPin2 = 7; 8const int echoPin2 = 6; 9const int led = 13; 10int sensorPin = A0; 11int sensorValue; 12int limit = 950; 13const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; 14LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 15float moisture; 16bool wet = false, obs2 = false; 17 18void setup() 19{ 20 lcd.begin(16, 2); 21 lcd.print("Waste Segregator"); 22 myservo.attach(10); 23 pinMode(trigPin1, OUTPUT); 24 pinMode(echoPin1, INPUT); 25 pinMode(trigPin2, OUTPUT); 26 pinMode(echoPin2, INPUT); 27 pinMode(led, OUTPUT); 28 myservo.write(pos); 29} 30 31// UV Obstacle Sensing Function 32bool obstacle(int trigPin, int echoPin, String s1){ 33 34 //for(int i=0;i<5;i++){ 35 //UV code 36 long duration, distance; 37 digitalWrite(trigPin, HIGH); 38 delayMicroseconds(1000); 39 digitalWrite(trigPin, LOW); 40 duration = pulseIn(echoPin, HIGH); 41 distance = (duration/2) / 29.1; 42 Serial.print(distance); 43 Serial.println("CM"+s1); 44 delay(10); 45 46 if(distance<=12) return true; 47 else return false; 48 //} 49 50} 51 52// Soil Moisture Sensor Code 53bool wetSense(){ 54 55 for(int i = 0; i < 8 ; i++) { 56 sensorValue = analogRead(sensorPin); 57 moisture = (100 - (sensorValue/1023.0)*100); 58 Serial.println("Analog Value : "); 59 Serial.println(sensorValue); 60 Serial.println("Moisture : "); 61 Serial.print(moisture); 62 Serial.println("%"); 63 if(sensorValue < limit){ 64 return true; 65 } 66 delay(500); 67 } 68 return false; 69} 70 71//LCD Display 72 73void printer(String s){ 74 75 lcd.setCursor(0, 1); 76 lcd.print(s); 77 delay(2000); 78 79} 80 81void loop() 82{ 83 Serial.begin(9600); 84 printer(" Monitoring... "); 85 if(obstacle(trigPin1, echoPin1,"one") == true){ 86 87 delay(11500); 88 for(int i = 0 ; i < 5 ; i++ ) { 89 obs2 = obstacle(trigPin2, echoPin2,"two"); 90 delay(200); 91 if(obs2 == true) { 92 delay(5300); 93 wet = (wetSense()); 94 break; 95 } 96 } 97 98 if(obs2==true && wet==true){ 99 100 myservo.write(pos+190); 101 printer(" Wet Waste "); 102 } 103 else if(obs2==true && wet==false){ 104 myservo.write(pos); 105 printer(" Dry Waste "); 106 myservo.write(pos); 107 } 108 else if(obs2==false) 109 printer(" Magnetic Waste "); 110 111 delay(2000); 112 } 113 delay(1000); 114
Downloadable files
Similar Circuit
Similar Circuit

Comments
Only logged in users can leave comments