Reverse Vending Machine (RVM)
Designed a machine in which the user can dispose plastic and metal waste and redeem points to collect rewards by scanning the QR code.
Components and supplies
Jumper wires (generic)
GPS Module (Generic)
Inductive Proximity Sensor, 15 mm
Single Turn Potentiometer- 100k ohms
Buzzer, Piezo
Ultrasonic Sensor - HC-SR04 (Generic)
Arduino Mega 2560
SG90 Micro-servo motor
Battery, 12 V
Alphanumeric LCD, 16 x 2
Breadboard (generic)
NodeMCU ESP8266 Breakout Board
9V battery (generic)
5 mm LED: Red
Capacitive Proximity Sensor, 12 mm
Switch Actuator, Head for spring return push-button
Tools and machines
Mastech MS8217 Autorange Digital Multimeter
Soldering iron (generic)
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Apps and platforms
Blynk
ThingSpeak API
Arduino IDE
Project description
Code
Waste Segregation
c_cpp
1#include <LiquidCrystal.h> 2 3//#include "Arduino.h" 4//#include "Button.h" 5#include <Servo.h> 6LiquidCrystal lcd(1,2,4,5,6,7); 7const int knapp = 3; 8int ButtonState = 0; // current state of the button 9int oldButtonState = 0; 10const int ledPin1 = 10; 11const int ledPin2 = 11; 12const int buzz1 = 12; 13const int buzz2 = 13; 14const int plasticsensor=A0; 15int metalsensor= A1; 16int metalsensor_M= A2; 17Servo myservo; 18Servo myservo_M; 19int pos = 90; 20int pos_M = 360; 21 22 23 24void setup() { 25 pinMode(knapp, INPUT); 26 digitalWrite(knapp, LOW); 27lcd.begin(16,2); 28lcd.clear(); 29 30 myservo.attach(9); 31 myservo_M.attach(8); 32 pinMode(plasticsensor,INPUT_PULLUP); 33 pinMode(metalsensor,INPUT_PULLUP); 34 pinMode(metalsensor_M,INPUT_PULLUP); 35 pinMode(ledPin1, OUTPUT); 36 pinMode(ledPin2, OUTPUT); 37 pinMode(buzz1, OUTPUT); 38 pinMode(buzz2, OUTPUT); 39 40 Serial.begin(9600); 41} 42 43 void loop() { 44 lcd.setCursor(0,0); 45 lcd.print("INSERT METAL ON"); 46 lcd.setCursor(0,1); 47 lcd.print(" RIGHT SIDE "); 48 delay(6000); 49 lcd.clear(); 50 int sensor_read=digitalRead(plasticsensor); 51 Serial.println("plastic sensor"); 52 Serial.println(sensor_read); 53 //delay (10); 54 int sensor_read_m=digitalRead(metalsensor); 55 //Plastic bin 56 Serial.println("metal sensor1"); 57 Serial.println(sensor_read_m); 58 //delay (10); 59 int sensor_read_mm=digitalRead(metalsensor_M); 60 Serial.println(sensor_read_mm); 61 //delay (10); 62 63 64 65 if((sensor_read==1)&&(sensor_read_m!=1)){ 66 for (pos = 90; pos <=240; pos += 1) { // goes from 0 degrees to 180 degrees 67 // in steps of 1 degree 68 myservo.write(pos); 69 // tell servo to go to position in variable 'pos' 70 //delay(5); 71 digitalWrite(ledPin1, HIGH); 72 digitalWrite(buzz1, HIGH); 73 74 // waits 15ms for the servo to reach the position 75 } 76 //delay(5000); 77 for (pos = 240; pos >=90; pos -= 1) { // goes from 0 degrees to 180 degrees 78 // in steps of 1 degree 79 myservo.write(pos); 80 //delay(5); 81 82 } 83 } 84 else { 85 // goes from 180 degrees to 0 degr 86 87 myservo.write(pos); 88 digitalWrite(ledPin1, LOW); 89 digitalWrite(buzz1, LOW); 90 } 91 92 if((sensor_read_mm==1)&&(sensor_read==0)){ 93 for (pos_M =360; pos_M >= 50; pos_M -= 1) { // goes from 0 degrees to 180 degrees 94 // in steps of 1 degree 95 myservo_M.write(pos_M); 96 97 //delay(5); 98 digitalWrite(ledPin2, HIGH); 99 digitalWrite(buzz2, HIGH); 100 } 101 // tell servo to go to position in variable 'pos' 102 // delay(5000); 103 for (pos_M = 50; pos_M <=360; pos_M += 1) { // goes from 180 degrees to 0 degrees 104 myservo_M.write(pos_M); // tell servo to go to position in variable 'pos' 105 //delay(5);// waits 15ms for the servo to reach the position 106 } 107 } 108 else{ myservo_M.write(pos_M); 109 digitalWrite(ledPin2, LOW); 110 digitalWrite(buzz2, LOW); 111 } 112 113 } 114 115
Waste Segregation
c_cpp
1#include <LiquidCrystal.h> 2 3//#include "Arduino.h" 4//#include "Button.h" 5#include <Servo.h> 6LiquidCrystal lcd(1,2,4,5,6,7); 7const int knapp = 3; 8int ButtonState = 0; // current state of the button 9int oldButtonState = 0; 10const int ledPin1 = 10; 11const int ledPin2 = 11; 12const int buzz1 = 12; 13const int buzz2 = 13; 14const int plasticsensor=A0; 15int metalsensor= A1; 16int metalsensor_M= A2; 17Servo myservo; 18Servo myservo_M; 19int pos = 90; 20int pos_M = 360; 21 22 23 24void setup() { 25 pinMode(knapp, INPUT); 26 digitalWrite(knapp, LOW); 27lcd.begin(16,2); 28lcd.clear(); 29 30 myservo.attach(9); 31 myservo_M.attach(8); 32 pinMode(plasticsensor,INPUT_PULLUP); 33 pinMode(metalsensor,INPUT_PULLUP); 34 pinMode(metalsensor_M,INPUT_PULLUP); 35 pinMode(ledPin1, OUTPUT); 36 pinMode(ledPin2, OUTPUT); 37 pinMode(buzz1, OUTPUT); 38 pinMode(buzz2, OUTPUT); 39 40 Serial.begin(9600); 41} 42 43 void loop() { 44 lcd.setCursor(0,0); 45 lcd.print("INSERT METAL ON"); 46 lcd.setCursor(0,1); 47 lcd.print(" RIGHT SIDE "); 48 delay(6000); 49 lcd.clear(); 50 int sensor_read=digitalRead(plasticsensor); 51 Serial.println("plastic sensor"); 52 Serial.println(sensor_read); 53 //delay (10); 54 int sensor_read_m=digitalRead(metalsensor); 55 //Plastic bin 56 Serial.println("metal sensor1"); 57 Serial.println(sensor_read_m); 58 //delay (10); 59 int sensor_read_mm=digitalRead(metalsensor_M); 60 Serial.println(sensor_read_mm); 61 //delay (10); 62 63 64 65 if((sensor_read==1)&&(sensor_read_m!=1)){ 66 for (pos = 90; pos <=240; pos += 1) { // goes from 0 degrees to 180 degrees 67 // in steps of 1 degree 68 myservo.write(pos); 69 // tell servo to go to position in variable 'pos' 70 //delay(5); 71 digitalWrite(ledPin1, HIGH); 72 digitalWrite(buzz1, HIGH); 73 74 // waits 15ms for the servo to reach the position 75 } 76 //delay(5000); 77 for (pos = 240; pos >=90; pos -= 1) { // goes from 0 degrees to 180 degrees 78 // in steps of 1 degree 79 myservo.write(pos); 80 //delay(5); 81 82 } 83 } 84 else { 85 // goes from 180 degrees to 0 degr 86 87 myservo.write(pos); 88 digitalWrite(ledPin1, LOW); 89 digitalWrite(buzz1, LOW); 90 } 91 92 if((sensor_read_mm==1)&&(sensor_read==0)){ 93 for (pos_M =360; pos_M >= 50; pos_M -= 1) { // goes from 0 degrees to 180 degrees 94 // in steps of 1 degree 95 myservo_M.write(pos_M); 96 97 //delay(5); 98 digitalWrite(ledPin2, HIGH); 99 digitalWrite(buzz2, HIGH); 100 } 101 // tell servo to go to position in variable 'pos' 102 // delay(5000); 103 for (pos_M = 50; pos_M <=360; pos_M += 1) { // goes from 180 degrees to 0 degrees 104 myservo_M.write(pos_M); // tell servo to go to position in variable 'pos' 105 //delay(5);// waits 15ms for the servo to reach the position 106 } 107 } 108 else{ myservo_M.write(pos_M); 109 digitalWrite(ledPin2, LOW); 110 digitalWrite(buzz2, LOW); 111 } 112 113 } 114 115
Dustbin level monitoring
c_cpp
1#include "ThingSpeak.h" 2#include <ESP8266WiFi.h> 3#include <BlynkSimpleEsp8266.h> 4#include <TinyGPS++.h> 5#include <SoftwareSerial.h> 6#define BLYNK_PRINT Serial 7#define TRIGGER2 5 8#define ECHO2 4 9WiFiClient client; 10 11 12static const int RXPin = 4, TXPin = 5; // GPIO 4=D2(conneect Tx of GPS) and GPIO 5=D1(Connect Rx of GPS 13static const uint32_t GPSBaud = 9600; 14 15//if Baud rate 9600 didn't work in your case then use 4800 16unsigned long myChannelField = 1067056; // Channel ID 17const int ChannelField = 1; // Which channel to write data 18const char * myWriteAPIKey = "FMV95MD2A1J7Y8SP"; // Your write A 19 20 21TinyGPSPlus gps; // The TinyGPS++ object 22WidgetMap myMap(V0); // V0 for virtual pin of Map Widget 23 24SoftwareSerial ss(RXPin, TXPin); // The serial connection to the GPS device 25 26BlynkTimer timer; 27// You should get Auth Token in the Blynk App. 28 29char auth[] = "YVvgHBx9fIM1-yR_2XrGXXkKdIuEmrYL"; 30 31// Your WiFi credentials. 32// Set password to "" for open networks. 33char ssid[] = "diksha"; 34char pass[] = "diksha19"; 35 36unsigned int move_index = 1; 37 38void setup() { 39 40 Serial.begin (115200); 41 ss.begin(GPSBaud); 42 Blynk.begin(auth, ssid, pass); 43// timer.setInterval(5000L, checkGPS); 44 45 pinMode(TRIGGER2, OUTPUT); 46 pinMode(ECHO2, INPUT); 47 pinMode(BUILTIN_LED, OUTPUT); 48 WiFi.mode(WIFI_STA); 49 50 51 ThingSpeak.begin(client); 52} 53 54/*void checkGPS(){ 55 if (gps.charsProcessed() < 10) 56 { 57 Serial.println(F("No GPS detected: check wiring.")); 58 59 } 60}*/ 61void loop() { 62 63 64 if (WiFi.status() != WL_CONNECTED) 65 { 66 Serial.print("Attempting to connect to SSID: "); 67 Serial.println(ssid); 68 while (WiFi.status() != WL_CONNECTED) 69 { 70 WiFi.begin(ssid, pass); 71 Serial.print("."); 72 delay(100); 73 } 74 Serial.println("\ 75Connected."); 76 } 77 78 79 while (ss.available() > 0) 80 { 81 // sketch displays information every time a new sentence is correctly encoded. 82 if (gps.encode(ss.read())) 83 Serial.println("GPS Connected");//displayInfo(); 84 { 85 86 if (gps.location.isValid() ) 87 { 88 89 float latitude = (gps.location.lat()); //Storing the Lat. and Lon. 90 float longitude = (gps.location.lng()); 91 92 Serial.print("LAT: "); 93 Serial.println(latitude, 6); // float to x decimal places 94 Serial.print("LONG: "); 95 Serial.println(longitude, 6); 96 ThingSpeak.setField(3, latitude); 97 ThingSpeak.setField(4, longitude); 98 ThingSpeak.writeFields(myChannelField, myWriteAPIKey); 99 Blynk.virtualWrite(V1, String(latitude, 6)); 100 Blynk.virtualWrite(V2, String(longitude, 6)); 101 myMap.location(move_index, latitude, longitude, "GPS_Location"); 102 } 103 } 104 } 105 106 //long duration1, distance1; 107 long duration2, distance2; 108 109 digitalWrite(TRIGGER2, LOW); 110 111 delayMicroseconds(2); 112 113 114 digitalWrite(TRIGGER2, HIGH); 115 delayMicroseconds(10); 116 117 118 digitalWrite(TRIGGER2, LOW); 119 duration2 = pulseIn(ECHO2, HIGH); 120 distance2 = (duration2/2) / 29.1; 121 122 123 124 if (distance2 <= 5) { 125 126 Blynk.notify("Please!! empty the dustbin"); 127} 128 Serial.println("2 ultrasonic Centimeter:"); 129 Serial.println(distance2); 130 Blynk.virtualWrite(V6, distance2); 131 ThingSpeak.writeField(myChannelField, ChannelField, distance2, myWriteAPIKey); 132 delay(100); 133 Blynk.run(); 134 timer.run(); 135} 136 137 138
Downloadable files
Circuit Diagram
Circuit Diagram

Circuit Diagram
Circuit Diagram

Comments
Only logged in users can leave comments