[No.10] Invent a Trash Can That Opens by Itself!

Opening the lid of a trash can is surprisingly annoying... especially when your hands are full of trash... When you want to solve a "little problem" like that, leave it to SPACEBLOCK, the tiny computer for making things!! This time, let's upgrade a trash can so its lid pops open by itself when you go to throw something away. Here's the trash can we'll upgrade! It sits on your desk, so it's handy for tossing the wrapper from a snack you ate while studying. It'll come in handy during allergy season too!

For this upgrade, we'll use the "180° Micro Servo Motor" and the "IR Obstacle Avoidance Sensor Module."
What You Need & Getting Ready
- SPACEBLOCK Standard Package [SPACEBLOCK, USB cable, battery box]
- IR Obstacle Avoidance Sensor Module (obstacle avoidance sensor)
- 180° Micro Servo Motor (servo motor)
- A computer for programming

Connect the Add-On Parts to SPACEBLOCK

For the details, look at the next picture. The obstacle avoidance sensor has 4 pins, but you only use the 3 labeled "G," "V," and "S."

What Can a Servo Motor Do?

To program it, use the [Move servo (A0 (T2)) to (90) degrees] block in the "Output" category.

What Can the Obstacle Avoidance Sensor Do?
The obstacle avoidance sensor uses infrared light to detect whether there is an obstacle within a certain distance. This time, we'll use it to detect when a hand comes near the trash can.
It tells the computer whether there's an obstacle or nothing at all, but it can't tell how far away the obstacle is or how big it is. Sending just two kinds of information like this, "there is" or "there isn't," is called digital input.
When there's no obstacle, the obstacle avoidance sensor makes the voltage on its pin high, and when there is an obstacle, it lowers the voltage. We won't use them this time, but programs sometimes use the values true and false. With digital input, the program gets true when the voltage is high and false when the voltage is low.

To program it, use the [When the voltage of (A0) (rises)] block in the [Input] category. The voltage goes down when an obstacle is detected, so to program what happens when there's an obstacle, set it to [When the voltage of (A0) (falls)].

You can adjust how far away the sensor detects obstacles by turning a small knob on it, called a potentiometer, with a screwdriver. When the obstacle avoidance sensor is connected to SPACEBLOCK and the power is on, you can check whether it detects an obstacle by looking at its light.

A Program That Opens the Lid When You Hold Your Hand Over It
Now let's make a device that opens the trash can lid automatically when you go to throw something away. Here's how it works: when the obstacle avoidance sensor detects your hand coming to throw trash away, the servo motor opens the lid.
First, build the program as in the next picture.

Run the program and bring your hand close to the obstacle avoidance sensor. The servo motor whirs and moves, then 3 seconds later whirs back to where it started.
Watch it in the video.
Using the Servo's Power to Open the Lid

The plan is to attach this part inside the trash can and use it to push the lid up.


This spot takes some force, so reinforce it...

Here's how we attached it.

Set Up the Obstacle Avoidance Sensor


Here's what it looks like from above.

Test It & It's Done!!

Let's watch it in the video.

Let's watch a video of someone throwing trash away.
It opens so smoothly that it's kind of fun, and you'll want to keep throwing trash away! There are probably other ways to open a lid with a servo too. Try it yourself!
Let's keep solving everyday "problems" and "hassles" with your SPACEBLOCK inventions!!