Site Overlay

Homework4 – Analog Output

Considering the fact that Danny has to review tons of our homework every week, I will put my result at the beginning of the page. In this way, everyone can view it first, and then decide whether to see the details or not.

This week I made a smart garbage bin that can be opened / closed controlled by your own voice, and you can see the sound classification result on the screen (from top to bottom there were the confidences for each sound category: “noise”, “open”,”close”). See the video below (kind of funny).

The sound classification model cannot accurately recognize each class all the time. So there were lots of mistakes that computer made in the video.

Controlling the bin open / close by your command

1 Ideation

Since my speaker cannot function very well, I focused my design on how to make an interesting servo toy/machine/something. Due to the special features of servo, which were (1)spin fast in 180 degrees; (2)cannot spin continuously in 360 degrees, I designed several versions for servo.

Finally I chose the first idea. It seemed more interesting than idea2. And idea 3 could not be made in a week (especially for the design of decoration), although I liked it very much.

2 Implementation

Stage 1 – Output Side

Then the problem became, I didn’t know how to make the shovel-like tool. Firstly I used plastic spoon as the shovel, but it was hard to be fixed on the servo (And it was ugly!). So I began to find ways to make nice “shovel-like” components online. And lots of tutorials used 3D printing. So I was thinking, “why not have a try to use 3D printing as well?”

Luckily I found a blueprint shovel component online. So I printed the components I needed.

By adding the code, I could now control the shovel lifting up or down. The test codes were as follows:

Servo side code confirmed
Servo servoMotor;
int servoPin = 6;
int start = 1;

void setup() {
  servoMotor.attach(servoPin);  // sets servo pin
  Serial.begin(9600);           // initialize serial communications
  servoMotor.write(10); // initialize servo angle
void loop() { // lift up only once.

if (start == 1){
      int servoAngle = 100;
      start = 0;
Stage 2 – Input Side

I wanted add something more interesting on it. As I’ve already fixed the output side as Servo, what could I do to change the ways of input?

It occurred to me that I could use specific words to control its movement using Teachable Machine Model (which I just learnt on machine learning for the web class).

Revised Design

So I changed the input to a sound classifier. I trained the sound classifier model on Google’s Teachable Machine 2.0 and used it in my code, which was awesome!

I struggled for like 1 hour dealing with the Arduino<->browser serial communication. After Yen’s help, I finally made some progress for the Arduino<->browser serial communication. My little toy could lift up its shovel when I said “open” now.

Serial communication confirmed

<Tip> The p5.serverController and Arduino serial monitor, you can only choose one to open from these two. If you want to connect p5 serial with browser, you cannot open the serial monitor in Arduino. Otherwise you won’t see anything! The only solution is to use some LED lights to show whether the data from browser has been transmitted to Arduino.

My way to show see if the communication works is: (1) upload the Arduino code (with BUILT_IN_LED as signal); (2) open p5 serialController and connect to port; (3) open browser and function.

I retrained the model and let it be recognized my “open” and “close” command. It would lift up when I said “open” and stayed till I said “close”. I also revised the browser code to visualize the real-time sound classification results. This was what you saw at the beginning of this post.

3 Reflection

I am very proud of the implementation process of this assignment. To target and solve problems, to iterate and revise it. There still are some aspects I think I can improve. Firstly and most importantly, the functionality and usage scenarios were very limited in that I used other’s 3D printing design. That made the design less original and looked like a modification of other’s work (Eunchan Park, he is amazing! Check his website). One way was to explore a better usage scenario when the idea of input and output side is fixed.
And! I Should learn something about 3D modeling. This will give me freedom to design with less limits.

Hmm… I still want to explore my idea 3, which is super cool if I can figure out a complete design. It can be designed as a mysterious treasure box that can show up different (and random) gift to whoever say “open”.

Maybe the treasure box looks like this?

Trying to think much more clearly!!! Maybe I need to talk to Danny.

4 Credits and Appendix

Thanks Yining for teaching machine learning for the web class! I do learn a lot.
Thanks Google Creative Lab for the access of Teachable Machine 2.0. And the 2.0 is super super amazing!
Thanks Eunchan Park for the blueprint of 3D printing models. His website:
Thanks Yen for helping solve Arduino problems!

My source code can be found here:

(I just began to learn front-end coding! So excited but still struggling with it. So forgive me with my stupid html/css code).

Leave a Reply

Your email address will not be published. Required fields are marked *