Machine learning in PCOM – Final

The Dispenser

https://teachablemachine.withgoogle.com/train/audio/1KONcm8ErSCHBjo_2JNjcClir7urEnhDR

For final, I experimented with the dispenser about two materials.

My first idea for a dispenser is,
When I come home from outside and need to wash my hand, I wanted to make an automatic hand soap dispenser to drop liquid soap on my hand so that I don’t need to touch anything with my dirty hand.
I thought this was more necessary for me because of covid19.

But it was not easy to control liquid soap with a servo motor as follows.
(here, I shouted ‘binu’ and binu is Korean for handsoap.)

I put liquid soap in a small empty bottle and hung it upside down to cover the hole in the bottle with a fan of the servor motor but it was not easy as the liquid was keep flowing.
So, Next time I try, I think I need something to control the pumping of this liquid type.

  • Handsoap dispenser

So instead of liquid, I tested with candy which is more easy to handle.
I trained my sound model( sound classifier) in the teacherble machine as a ‘banana’ because I love banana.

/28 samples of bananas/background noise 20 seconds.

When I shouted banana, I controlled the angle of the servo motor so that the yellow candy fell from the dispenser.
Then, I put the servo motor in an empty paper box and made a dispenser to put candies.

  • Candy dispenser

Question & Next step

  • The challenge I faced here was to distinguish the Banana sound from the background noise class.
    I think my sound model worked just fine but Sometimes I felt like the servo motor was out of control.

In other words, I recorded the background noise in silence in teachable machine, but when I brought this ml5 sound model to the p5 sketch, Banana sound and background noise were repeated alternately.

I felt that the background noise and banana sound were not really distinguished, so the motor went back and forth between 90 and 0 degrees.
– So when I train background noise, How can I train this without this problem?

  • How to let only one piece of snack out at a time
    When I put a bunch of candies in the dispenser and they came out at once, not one at a time.
    I think I need to study how to make it come out one at a time.

  • For liquid type of dispenser, I need to figure out how to control the server motor. What is an effective way to control hand soap pumping? with servor motor or anthing else?
#include <Servo.h>

Servo myservo;
int servoPin = 9;
int ledPin1 = 2;
int ledPin2 = 3;

void setup() {
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);

  myservo.attach(servoPin);
  myservo.write(0);  // set servo to mid-point

  // start serial port at 9600 bps:
  Serial.begin(9600);
}

void loop() {
  if (Serial.available() > 0) { // if there's serial data available
    int inByte = Serial.read(); // read it
    Serial.println(inByte);
    if (inByte == 1) {
      myservo.write(90);
      // Light red LED
      digitalWrite(ledPin1, HIGH);
      digitalWrite(ledPin2, LOW);
    }

    else {
      myservo.write(0);
      digitalWrite(ledPin1, HIGH);
      digitalWrite(ledPin2, HIGH);

    }
    delay(500);
  }
}