In the Dutch theme park de Efteling they have a talking trashcan called Holle Bolle Gijs for over 50 years now! To honour this, I made a ‘in house’ version of Gijs. Gijs is made of paper mache, some carton and acryl paint. For the electronics I use a light sensor, and an Arduino connected to a mp3 player. When the Arduino detects movement in the mouth of Gijs, it plays a sound from the mp3 player. When there is no detection of movement, the Arduino keeps on playing a sound to attract attention.
See this video of my end result.
Step 1: The Electronics / Interaction
Ok so this tutorial is still a little bit of mash-up of other tutorials which I need to replace with my own writing and add some images. Still I think in its current state it fulfils the promise of being a tutorial and describes the steps needed to make a talking trashcan.
We want the talking trashcan to have 2 different talking modes.
Mode 1: ask for trash
Mode 2: respond to trown in trash
To support these 2 modes we need: something to determine the modes (an actuator), a microcontroller to make decisions and something to play the sounds.
For the actuator I describe the usage of an LDR.
For the sound I describe the adafruit audio shield
To detect the different modes we need an actuator. I chose to use a light dependent resistor (LDR). If the LDR detects lots of light I know that there is nothing covering the mouth of Gijs (mode 1) and if the LDR detects no or little light then something (trash) is blocking the light in the mouth of Gijs (mode 2).
I chose to use the LDR, since the first talking trashcan from 50 years ago used a simular method and I found it an easy and cheap solution. If you don't like my approach you can think of all type of different actuators and even improve my setup. Please feel free to do so and post your solution in the comments.
For this tutorial I assume you know how to use an LDR with an Arduino. If you have never used an LDR before take a look at this instructable https://m.instructables.com/id/How-to-Use-a-Light-Dependent-Resistor-LDR/
OK, so we all now know how to use an LDR with an Arduino. Now connect the LDR with the Arduino and check if you are able to read the value of the LDR.
When you are able to read the value of the LDR determine on what value you want to switch between the 2 modes.
Store this mode as an integer variable with the name threshold.
Now create an if clause in the loop to determine if the LDR value is below the threshold. If the LDR value is below the threshold turn the led pin 13 off. If the LDR value is above the threshold turn led pin 13 on. To control a led pin read this page http://arduino.cc/en/Tutorial/Blink?from=Tutorial.BlinkingLED
If you have successfully implemented the if clause with the led pin you see that the led is turned off when there is no of little light and on when there is more light. (This could be opposite depending on your type of LDR and implementation)
You might also notice that the led is turned off and on quite fast. This is because we use the current LDR value which can change very fast.
To make the value change more fluently we can implement a buffer and smooth our readings. The buffer will contain the last 10 readings which we will average to get a value which we compare with our threshold. We can use an Array to create our buffer. On the Arduino site is a great tutorial on how to create a buffer. http://arduino.cc/en/Tutorial/Smoothing
Implement this type of smoothing in your sketch and use the average to compare with your threshold value. If your led is still changing to fast for your idea try playing with the Array size. I found a size between of 50 the most desirable. It gave my system a good response but did not gave to many false positives.
OK so we are able to detect the 2 modes using our actuator and the Arduino. Now it is time to make some noise! We simply have to replace the led turning on/off with playing a sound.
There are many different ways to make sounds with an Arduino. You can use beeps ( https://m.instructables.com/id/Arduino-Basics-Making-Sound/ )
an Arduino audio/mp3 shield ( https://www.sparkfun.com/products/10628)
or as I did hack an MP3 player. (I added a schematic of my implementation. Here I control the MP3 player with relay switches)
Hacking an MP3 player is actually the worst of all options, so if you want a durable solution go for the shield.
Adafruit has a nice audio shield tutorial which you can use https://learn.adafruit.com/adafruit-wave-shield-audio-shield-for-arduino.
I would advice to modify this example for you talking trashcan. https://learn.adafruit.com/system/assets/assets/000/010/343/original/wavehc_play6completeoneloop.pde.txt
In stead of switching sounds using the buttons you can switch sounds using the if clause you made with your actuator.
And that's it! You have made the technology to make a talking trashcan!
Now all you need to do is implement the tech in your trashcan. I chose to make a head with paper mache and implement the LDR in the mouth with a led shining on the LDR. This way I know for sure the LDR will only stop detecting light if something passes through the mouth and not if somebody puts his hand in front of the mouth.
How to make a paper manche head you ask? Here you can find a simular approach as mine. https://m.instructables.com/id/Creating-a-papier-mache-head-of-Felix-Morton/?ALLSTEPS
The one big difference is that I made a throat to guide the thrash and implement the actuator.
That is probably all you need to know to make your own talking trashcan.
Good luck building it and post your results and questions in the comments.