Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Hackster is hosting Impact Spotlights: Industrial Automation. Watch the stream live on Thursday!Hackster is hosting Impact Spotlights: Industrial Automation. Stream on Thursday!
Rico_Candra_Prayudi
Published © GPL3+

Robot Trash

A simple robotic trash that will attract you to throw your waste by open its lid and produce sound.

IntermediateProtip1,968
Robot Trash

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
DFPlayer Mini Mp3 Modul
×1
Ceiling Speaker, Two-Way
Ceiling Speaker, Two-Way
×1

Story

Read more

Schematics

SCHEMATIC

Code

Code

Arduino
For this project, we used a simple coding by using Arduino.IDE app.
#include<Servo.h>
#include <SoftwareSerial.h>
#include <DFPlayer_Mini_Mp3.h>

SoftwareSerial mySerial(10, 11);
 
Servo servo;
int const trigPin = 6;
int const echoPin = 5;
void setup()
{
  Serial.begin (9600);
mySerial.begin (9600);
mp3_set_serial (mySerial);
delay(10);
pinMode(trigPin, OUTPUT); 
pinMode(echoPin, INPUT); 
    servo.attach(3);
}
void loop()
{       int duration, distance;
digitalWrite(trigPin, HIGH); 
delay(1);
digitalWrite(trigPin, LOW);
// Measure the pulse input in echo pin
duration = pulseIn(echoPin, HIGH);
// Distance is half the duration devided by 29.1 (from datasheet)
distance = (duration/2) / 29.1;
// if distance less than 0.5 meter and more than 0 (0 or less means over range) 
if (distance <= 20 && distance >= 0) {
  servo.write(50);
    delay(3000);
} else {
  
  servo.write(160);
 void setup () ;
{ 
mp3_set_volume (95);
delay(10);
mp3_play ();
delay(10);
mp3_play (1);
delay(10);
}
}

// Waiting 60 ms won't hurt any one
delay(40);
}

Credits

Rico_Candra_Prayudi
0 projects • 1 follower
Contact

Comments

Please log in or sign up to comment.