Daphne
Published © GPL3+

Touchless Automatic Dustbin

As we are living in a pandemic, developing products with a touchless function will undoubtedly assist to limit contact.

BeginnerShowcase (no instructions)1 hour80
Touchless Automatic Dustbin

Things used in this project

Hardware components

RTL8722DM_MINI
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1

Story

Read more

Code

Programming

C/C++
The source code could found in my github: https://github.com/daphwl/Touchless-Automatic-Mini-Dustbin
void loop() 
{
  float duration,distance;
  digitalWrite(trigger_pin,HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigger_pin, LOW);
  duration = pulseIn(echo_pin,HIGH);
  distance = (duration/58);
  Serial.print(distance);
  Serial.println(" cm");
  time = time + inter_time;
  delay(inter_time);
  if(distance < 10)
  {
    for(int i = 1500; i>= 1100; i-=25)
    {
      myservo.writeMicroseconds(i);
      Serial.println("2");
      delay(1000);
    }
    delay(1000);
    for(int i=1100; i<=1500; i+=25)
    {
      myservo.writeMicroseconds(i);
      Serial.println("1");
      delay(1000);
    }
    }
  }

Credits

Daphne
12 projects • 1 follower
Always ready to learn something new...
Contact

Comments

Please log in or sign up to comment.