AI Auto-Classify Trash Can




Introduction: AI Auto-Classify Trash Can


This Instructable is out of date.

Due to the platform which you need in this project is no longer available for some functions.

This is educational project, a trash can that recognizes and classifies garbage automatically.

Use Machine-Learning and Arduino in Scratch.

How it works

1. Camera takes an image of garbage.

2. Machine-Learning model recognizes the classification of garbage by the image.

3. Electrical and mechanical parts drive the garbage into diffrent palce by its classification.


Machine-Learning, Block-coding and 3D-design platforms in this project are designed for kids, easy and free to use.


Computer, USB-Camera, 3D-Printer

Arduino UNO

Servo motor (control angle 0-180°)

Servo motor (control angle 0-270°)

Step 1: Working Demo

How it works is shown above.

Step 2: Teach Computer to Recocognize Garbage

Machine Learning is the core technology of Artificial Intelligence.

By it, computer can recognize image and text.

Machine Learning For Kids is an educational website to make machine-learning model and use it in Scratch.

1. Go to Machine Learning For Kids, sign up and log in

It's free to use, but a little bit complicated when signing up.

Because during signing up, you need to get free API Keys from IBM Cloud.

There's step-by-step instructions on the sign up page, just follow it.

2. Add a new project

Name the project, choose 'Recognizing images' , choose 'In the cloud'.

and click 'CREATE'.

Step 3: Take Images and Lable Them


We can train a computer recognizing objects like training a human baby.

Imagine you're teaching a baby to recognize apple.

You may hold an apple in front of the baby and tell him it's 'apple'.

By this way, the baby gets images of apple and gets the lable 'apple'.

Then the baby associates the images and the lable.

After this training, when the baby sees an apple, he knows it's 'apple'.

In the same way, we give computer images of objects, and tell computer what are the objects by labling the images.

After clicking 'CREATE', the page changes automatically.

Click your project name to choose your project and click 'Train'.

Click 'Add New Lable', name the lable and input images that belong to the lable.

Now, we want to teach computer to recognize the images of garbage.

In my city, the policy devides garbage into four kinds -- Recyclable, Hazardous, Household food, and Residual. So I add these four lables and input images of garbage by USB-Camera.

(In industry, professional people may make hundreds of lables, one lable for one object, and take thousands images for each object.

In this cost-free eduactional website, the maximum number of images you can input is 100 in total.

So In these simple project, I just add four lables by the classifaictions of garbage, and choose 2 examples to take images for each lable. For example, I find batteries and expired medicine as the examples for Hazardous garbage, and take 20 images of them with USB-Camera. )

Step 4: Learn and Test

After adding lables and inputing images, click 'Back to project', go to the previous page and click 'Learn & Test'.

Right now, computer has lables and images, but it has not learned yet.

In the learning process, computer tries to find the characteristics of object in those images.

The algorithm is complex and the system requirements is high.

But don't worry, this process automatically runs on IBM cloud. (That's why you need IBM API keys when signing up.)

Click 'Train New Machine Learning Model' to get it started.

It will takes a few minutes.

When learning is over, you can input image to test your model.

If it does not work well, you may go back to Train page, input more images or replace old images and train a new model.

Step 5: Use Maching-Learning Model in Scratch

Click 'Back to project', go to the previous page and choose 'Make'.

You can use your machine-learning model in different platforms.

In this project, I use Scratch, not Scratch3. Because in this old version of Scratch, we can load other un-official extensions such as extension for Arduino Uno.

Choose 'Scratch', go to the coding page. Then you may see blocks of your machine-learning model. With them you can use machine-learning model to recognize images in Scratch.

Step 6: Load Extension for Arduino Uno

At the beginning I wanted to use micro:bit in this project, but the extension for micro:bit provides no blocks to drive servo motor. Instead I use Arduino Uno, and find an extension for it.

To use Arduino Uno in Scratch, you need to do some steps first.

Follow instuctuons in this page:

Then go back to scratch page of MachinelearningForKids, click 'More blocks' - 'Load Experimental Extension' and input this URL:

(This extension is from ScratchX. But the original URL of it cannot be loaded in MachinelearningForKids. So I put the extension in this above URL.)

Input the URL and Click 'Open'. Then you may see blocks of Arduino Uno.

Step 7: 3D-Print and Code

This trash can is designed in Tinkercad.

You can look inside the structure in this URL.

The example codes of how to use machine-learning model and arduino in Scratch are shown in the first picture.

The codes of my trash can are very easy, shown in the second piciture.

Step 8: Final Words

This project is an educational project in my STEM club.

It involves Machine-learning, Scratch, Arduino and 3D-Printing. The platforms to make it are free and easy to use.

I publish this Instructable not to help you make a same trash can.

But if you are a beginner who want to make something with machine-learning and arduino, you can use the same ways in this project. They are enough to make a prototype like my AI trash can.

Block Code Contest

Participated in the
Block Code Contest

Be the First to Share


    • Teach With Tinkercad Contest

      Teach With Tinkercad Contest
    • Halloween Contest

      Halloween Contest
    • Metal Contest

      Metal Contest



    10 months ago


    I have a problem on the download step of the extension for Arduino.
    Indeed, I don't have the button "Load Experimental Extension" and when I click on the link "Straight into Scratch" the page doesn't load.

    Would you have a solution please?

    Thanks in advance

    Kim Chengdu
    Kim Chengdu

    Reply 10 months ago

    This project was made long time ago.

    And the MachineLearningForKids(ML4K) platform has some changes.

    Old version of Scratch is no longer used in ML4k, if you make a project to recognize image.(But text reconizition still works for old-version scratch)

    And on ML4K, the new-version Scracth 3, cannot use with Arduino.
    Sorry for that.

    Try to copy this link open it in your web-browser to open the old-version Scratch.

    If it does not work, I don't have other solution right now.

    Kim Chengdu
    Kim Chengdu

    Reply 10 months ago

    Perhaps your problem is for another reason.
    Old-version Scratch is based on Adobe Flash Player.

    And many browsers no longer support for it.
    Some browser settings may allow to use Adobe Flash Player.

    Gaganram PM
    Gaganram PM

    1 year ago

    i cant see other option in 'make' tab.... i can see only scratch 3.... where are the other....
    PLEASE help.....
    this is a nice project i want to make it please help

    Kim Chengdu
    Kim Chengdu

    Reply 1 year ago

    I just checked it, there's a change.
    When you create a project,after inputing name and choosing 'image', a new option appears.

    Choose 'In the cloud', not 'on your computer'. 'on you computer' is Scratch3 only.

    Kim Chengdu
    Kim Chengdu

    Reply 1 year ago

    If your project is already created. In the 'Learn & Test' page, you can make a change.

    Kim Chengdu
    Kim Chengdu

    Reply 1 year ago

    I guess you chose 'Try it now' on the login page.
    In 'Try it now' mode, only Scratch3 is available.
    Try sign up and log in, then you may see it.
    Glad you like it!

    Gaganram PM
    Gaganram PM

    Reply 1 year ago

    I signed up but there is only scratch 3


    1 year ago

    Nice project. Thank you for sharing.