Introduction: Smart Trash Can

About: Hello!

Video Link:


https://vimeo.com/753168697/fce6a2414f



Every year, 20 million tons of trash ends up in our oceans. 100,000 sea creatures die each year due to that trash, and nearly 66% of sea creatures have been entangled or harmed by it. There are currently 525,000,000,000,000, or 5.25 TRILLION pieces of trash in our ocean, and that number is only going up. There is more plastic in our ocean than fish!


Yet only 48% of Americans recycle and 64% of us acknowledge climate change according to a survey. Why is this? Why do we not bother to take a moment out of our life to stop, and this about the effect of trashing a recyclable item? But every time you stand over the bin, throwing away your recyclable plastic bottle, there is a 66% chance that will harm a fish.


75% of our waste is recyclable. But I'm sure that when you pull your bins out to the street that both bins are the same size. That is because we only recycle 40% of what can be recycled.


If you start recycling, you can save nearly 600 fish and 900 pounds of waste ending up in our ocean yearly!


What can increase recycling? That was my question going into this project...

Supplies

$8 Desktop Trash Can

$10 for Two Different Paints

$7 Camera (Make sure it is compatible with the board/computer)

$6 Servo Motor x2

_______________________________________________________________________________________________

For this project it will work better with Rasbery Pi. I do not have access to one because of the cost, so both Arduino and Rasbery Pi will work. If you are using Arduino you must connect to the computer, so 2 extension cords ($8) will be needed.

$18 Arduino

or

~$110 Rasbery Pi

_______________________________________________________________________________________________

+Jumper Wires

_______________________________________________________________________________________________

Comes out to ~ $60. An average trash can come out to around $20 - $30. For an extra $7, you can recycle 900 lbs extra yearly.

Step 1: Structure

The first step is to build the structure. You will need your trash can, your Arduino (or Rasbery pi), anything that can act as a divider, as well as an extension cord if you are using Arduino.

  • Mount your Arduino/ Rasbery Pi to the trash can. To make it look better, embox your Arduino/Rasbery pi.
  • Mount your divided across the middle of the can. Hot glue will work fine- Make sure the divider is not taller than the height of the can.
  • If you are using Arduino - connect with an extension cord, then to a computer. This is to maintain a serial communication with python.

Step 2: Brainstorming and Categorizing

The next step is to think about what makes an item recyclable or not, visually. Then, make 2 groups, recyclable and trash. Gather these materials and think about any variation of it. For instance, I came up with a list of recyclable items, and non-recyclable items. Under each of those categories, like cans, I chose a variety of sodas, and some were dented, some were crushed, others were new. After brainstorming, you are ready for the next step.


Step 3: OpenCV

The next step is to make a computer vision AI. This is fairly easy, and there is two ways to do this. you can use Cascade Trainer GUI, or Google's Teachable Machine. Both will work. I used the Teachable Machine:

  • Take you pictures- make sure that the camera is the same distance away from the surface, and that it is closer than 10 inches (I'll explain later)
  • Take the pictures with good lighting, consistently
  • Take the pictures from many different angles
  • Take a lot of pictures
  • Have the surface the same in every picture

If you are using teachable machine export the model as tensorflow -> keras. Disregard the code given to you.

Step 4: Python Code

This will be for a keras file:

If you used Cascade Trainer, it will be similar, just a different file type, and a different way to access the file.

This is only necessary if you are using Arduino.


import cv2

import cvzone

from cvzone.ClassificationModule import Classifier

import serial

import time

data = serial.Serial('com4', baudrate = 9600)


cap = cv2.VideoCapture(1)


classifier = Classifier('rec/keras_model.h5','rec/labels.txt')


while True:

  _, img = cap.read()

  pred, index = classifier.getPrediction(img)

  print(pred, index)


  cv2.imshow("img",img)

  cv2.waitKey(1)

  if (index == 0):

    recycle = 1

  if (index == 1):

    recycle = 1

  if (index == 2):

    recycle = 1

  if (index == 3):

    recycle = 1

  if (index == 4):

    recycle  = 1

  if (index == 5):

    recycle = 1

  if (index == 6):

    recycle = 1

  if (index == 7):

    recycle = 3

  if (index == 8):

    recycle = 3

  if (index == 9):

    recycle = 2

  def recy():

    data.write(b'1')

  def neu():

    data.write(b'2')

  def tra():

    data.write(b'3')

  t=0

  while(t<2000):

    if(t % 10 == 0):

      print(t)

    t+=1

  if(recycle == 1):

    recy()


  if(recycle == 2):

    neu()


  if(recycle == 3):

    tra()

Step 5: Arduino Code

Arduino Code:

This will be the same no matter how you did step 4:


#include <Servo.h>

Servo motor;

Servo motorb;


char serialData;


int n = 7;

int m = 7;

int p = 7;


void setup() {

Serial.begin(9600);

motor.attach(10);

motorb.attach(3);

}


void loop() {

if(Serial.available() > 0){

serialData = Serial.read();

Serial.print(serialData);

}

if(serialData == '1'){

n = n+1;

}

if(serialData == '2'){

p = p+1;

}

if(n == 8){

 motor.write(360);

  motorb.write(0);

  delay(300);

   motor.write(90);

   motorb.write(90);

      delay(1700);



 n=n-1;

}

if(serialData == '3'){

m = m+1;


}

if(m == 8){

 motor.write(0);

   motorb.write(360);

 delay(300);

   motor.write(90);

   motorb.write(90);

      delay(1700);


 m=m-1;

}

if(p == 8){

 motor.write(90);

   motorb.write(90);

 delay(300);

   motor.write(90);

   motorb.write(90);

   delay(1700);

 p=p-1;

}

}

Step 6: Rasbery Pi

For the Rasbery Pi code, you would just connect your camera, access your trained file. You would then have all if statements to determain if an object is recyclable or not. Then, you can make the servo motor angles execute simularly.

Step 7: Top Platform

Now you need to attach the last part of the can- you will need a camera, some sticks (popsicle will work), 2 servos, and a platform. The platform must be the same color as the one you took your pictures on.

  • Attach the 2 servos on either side of a small platform
  • Adjust your camera angle to where the camera captures the entire platform

Next you will build a stand for the camera. It will look like an upside-down 'L'. The longer side must be the same distance as your camera was away from your objects while taking the pictures. The camera must face down towards the platform. Have your other side reach out to the middle of the platform. Then check to see if the camera's angle catches the whole platform, and that the model works. If you are using Arduino, connect it to the computer, if you are using Rasbery Pi, connect to the board.


Then attach the platform and servos to the opening of the trash can.

Step 8: Closing and Sources

The thought would be that it takes less effort to recycle. People would be less hesitant to recycle, and it would be much more effortless to do so...


Thank you for checking out this project.


Recycling can save our planet one step at a time, so let's all make an effort to change, recycle, and save our planet - please consider donating to ocean-cleanup effort organizations: Homepage - Oceans' Harmony (oceansharmony.org)


How Many Marine Animals Die From Plastic Each Year? | Earth.Org

Ocean Trash: 5.25 Trillion Pieces and Counting, but Big Questions Remain | National Geographic Society

U.S. views on climate change differ by generation, party and more: Key findings | Pew Research Center

Young Americans may not be as committed to recycling - Recycling Today

National Overview: Facts and Figures on Materials, Wastes and Recycling | US EPA

Microcontroller Contest

Participated in the
Microcontroller Contest