SlideShare uma empresa Scribd logo
1 de 14
By :
Haris Panca
Muhammad Efantama
Kenanga Ayu Nirmala
This idea we got when we pay attention
to our surroundings clean, some people less
lazy throw away trash in its place amongst other
things because, if we have to throw away trash
pressing or touching the dumpster, therefore we
have an idea to make project of the
instrumentation, entitled "Trash" that can open
and close automatically so that people will dump
need not be touching or tapping the dumpster.
To bring back the community will want to
dispose of the waste in place, some of the trash made
as attractive as possible so that the public are
interested to dump garbage at the venue. One of them,
namely the trash with an automated system where to
open the dumpster, users do not need to touch the
dumpster. Users only need to stand in front of the
Ultrasonic sensors on the front, then the bin will open
automatically. In addition the bin is equipped with LEDs
so that when the bin is open green light will turn on and
when the trash can close the light is red.
Solder
Sciccors
Cutter
Glue
Laptop
Ruler
 Arduino Uno
 Sensor Ultrasonik
 Servo TowerPro SG90
 Buzzer
 Resistor 220Ohm
 LED (Red and Blue)
 PCB
 Acrylic
 Cable (M to M, M to F, and F to F)
 Trash Bin
http://www.farnell.com/datasheets/1682209.pdf
http://www.micropik.com/PDF/SG90Servo.pdf
http://www.micropik.com/PDF/HCSR04.pdf
http://www.tek.com/sites/tek.com/file
s/media/media/resources/Cables2.p
df
• Male to Male
• Male to Female
• Female to Female
#include <Servo.h>
Servo myservo;
#define buzzer 3
int sound;
#define trigPin 11
#define echoPin 10
#define led 6
#define led2 4
void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(buzzer, OUTPUT);
pinMode (led, OUTPUT);
pinMode(led2, OUTPUT);
myservo.attach(9);
}
void loop() {
long duration, distance;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/1) / 29.1;
if (distance >=0 && distance <= 20)
{
myservo.write(160);
tone(buzzer, 3000,150);
digitalWrite(led, LOW);
digitalWrite(led2, HIGH);
}
else if (distance > 20 || distance < 0){
myservo.write(0);
noTone(buzzer);
Serial.println("Jarak diluar jangkauan!");
digitalWrite(led, HIGH);
digitalWrite(led2, LOW);
}
else {
Serial.print(distance);
Serial.println(" cm");
}
delay(250);
}
Automatic trash can using Arduino

Mais conteúdo relacionado

Semelhante a Automatic trash can using Arduino

project instrumentasi smart house (smart trash bin)
 project instrumentasi smart house (smart trash bin) project instrumentasi smart house (smart trash bin)
project instrumentasi smart house (smart trash bin)Mimi Chinho
 
VAISHNO KANPUR INSTITUTE OF TECHNOLOGY PPT.pptx
VAISHNO KANPUR INSTITUTE OF TECHNOLOGY PPT.pptxVAISHNO KANPUR INSTITUTE OF TECHNOLOGY PPT.pptx
VAISHNO KANPUR INSTITUTE OF TECHNOLOGY PPT.pptxRuchi843636
 
Arduino-Based Smart Dustbin - Hemant Verma - Google Docs.pdf
Arduino-Based Smart Dustbin - Hemant Verma - Google Docs.pdfArduino-Based Smart Dustbin - Hemant Verma - Google Docs.pdf
Arduino-Based Smart Dustbin - Hemant Verma - Google Docs.pdfHEMANTVERMA6592
 
IRJET- Automatic Trash Can Buggy with IoT
IRJET-  	  Automatic Trash Can Buggy with IoTIRJET-  	  Automatic Trash Can Buggy with IoT
IRJET- Automatic Trash Can Buggy with IoTIRJET Journal
 
presentation of smart dustbin 9561.pptx
presentation of smart dustbin 9561.pptxpresentation of smart dustbin 9561.pptx
presentation of smart dustbin 9561.pptxfarhanmukhtiar
 
An Efficient Smart Garbage Disposal System - A Review
An Efficient Smart Garbage Disposal System - A ReviewAn Efficient Smart Garbage Disposal System - A Review
An Efficient Smart Garbage Disposal System - A Reviewijtsrd
 
Smart solution for collision at doors using Arduino
Smart solution for collision at doors using ArduinoSmart solution for collision at doors using Arduino
Smart solution for collision at doors using ArduinoAmon Olimov
 
Social distancing detection using arduino 1
Social distancing detection using arduino 1Social distancing detection using arduino 1
Social distancing detection using arduino 1ShubhamKashyap125
 
Use rotovac power wand technology for perfect carpet cleaning!
Use rotovac power wand technology for perfect carpet cleaning!Use rotovac power wand technology for perfect carpet cleaning!
Use rotovac power wand technology for perfect carpet cleaning!clenzphilly
 
Building of heart beat rate monitor &amp; object detector by md syeduzzaman s...
Building of heart beat rate monitor &amp; object detector by md syeduzzaman s...Building of heart beat rate monitor &amp; object detector by md syeduzzaman s...
Building of heart beat rate monitor &amp; object detector by md syeduzzaman s...Syeduzzaman Sohag
 
Open Source Wash Machine
Open Source Wash MachineOpen Source Wash Machine
Open Source Wash MachineAbout Us Blog
 
Automatic Collision Control System
Automatic Collision  Control SystemAutomatic Collision  Control System
Automatic Collision Control SystemSankhadeep Rakshit
 
Smart glove hand gesture vocalizer final year report
Smart glove hand gesture vocalizer final year reportSmart glove hand gesture vocalizer final year report
Smart glove hand gesture vocalizer final year reportMUHAMMAD NOMAN KHAN
 
Open Entrepreneurship for CERN
Open Entrepreneurship for CERNOpen Entrepreneurship for CERN
Open Entrepreneurship for CERNPaul Bristow
 
Smart dustbin using arduino and ultrasonic sensor
Smart dustbin using arduino and ultrasonic sensorSmart dustbin using arduino and ultrasonic sensor
Smart dustbin using arduino and ultrasonic sensorShaikhMohammedAmmar
 

Semelhante a Automatic trash can using Arduino (20)

project instrumentasi smart house (smart trash bin)
 project instrumentasi smart house (smart trash bin) project instrumentasi smart house (smart trash bin)
project instrumentasi smart house (smart trash bin)
 
iot project Smart dustbin ppt.pptx
iot project Smart dustbin ppt.pptxiot project Smart dustbin ppt.pptx
iot project Smart dustbin ppt.pptx
 
VAISHNO KANPUR INSTITUTE OF TECHNOLOGY PPT.pptx
VAISHNO KANPUR INSTITUTE OF TECHNOLOGY PPT.pptxVAISHNO KANPUR INSTITUTE OF TECHNOLOGY PPT.pptx
VAISHNO KANPUR INSTITUTE OF TECHNOLOGY PPT.pptx
 
Arduino-Based Smart Dustbin - Hemant Verma - Google Docs.pdf
Arduino-Based Smart Dustbin - Hemant Verma - Google Docs.pdfArduino-Based Smart Dustbin - Hemant Verma - Google Docs.pdf
Arduino-Based Smart Dustbin - Hemant Verma - Google Docs.pdf
 
IRJET- Automatic Trash Can Buggy with IoT
IRJET-  	  Automatic Trash Can Buggy with IoTIRJET-  	  Automatic Trash Can Buggy with IoT
IRJET- Automatic Trash Can Buggy with IoT
 
SMART DUSTBIN USING ARDUINO NANO
SMART DUSTBIN USING ARDUINO NANOSMART DUSTBIN USING ARDUINO NANO
SMART DUSTBIN USING ARDUINO NANO
 
presentation of smart dustbin 9561.pptx
presentation of smart dustbin 9561.pptxpresentation of smart dustbin 9561.pptx
presentation of smart dustbin 9561.pptx
 
An Efficient Smart Garbage Disposal System - A Review
An Efficient Smart Garbage Disposal System - A ReviewAn Efficient Smart Garbage Disposal System - A Review
An Efficient Smart Garbage Disposal System - A Review
 
el ppt second sem.pptx
el ppt second sem.pptxel ppt second sem.pptx
el ppt second sem.pptx
 
Smart solution for collision at doors using Arduino
Smart solution for collision at doors using ArduinoSmart solution for collision at doors using Arduino
Smart solution for collision at doors using Arduino
 
Social distancing detection using arduino 1
Social distancing detection using arduino 1Social distancing detection using arduino 1
Social distancing detection using arduino 1
 
Waste management
Waste managementWaste management
Waste management
 
Use rotovac power wand technology for perfect carpet cleaning!
Use rotovac power wand technology for perfect carpet cleaning!Use rotovac power wand technology for perfect carpet cleaning!
Use rotovac power wand technology for perfect carpet cleaning!
 
Building of heart beat rate monitor &amp; object detector by md syeduzzaman s...
Building of heart beat rate monitor &amp; object detector by md syeduzzaman s...Building of heart beat rate monitor &amp; object detector by md syeduzzaman s...
Building of heart beat rate monitor &amp; object detector by md syeduzzaman s...
 
Open Source Wash Machine
Open Source Wash MachineOpen Source Wash Machine
Open Source Wash Machine
 
Automatic Collision Control System
Automatic Collision  Control SystemAutomatic Collision  Control System
Automatic Collision Control System
 
Smart glove hand gesture vocalizer final year report
Smart glove hand gesture vocalizer final year reportSmart glove hand gesture vocalizer final year report
Smart glove hand gesture vocalizer final year report
 
Da sind die Roboter
Da sind die RoboterDa sind die Roboter
Da sind die Roboter
 
Open Entrepreneurship for CERN
Open Entrepreneurship for CERNOpen Entrepreneurship for CERN
Open Entrepreneurship for CERN
 
Smart dustbin using arduino and ultrasonic sensor
Smart dustbin using arduino and ultrasonic sensorSmart dustbin using arduino and ultrasonic sensor
Smart dustbin using arduino and ultrasonic sensor
 

Último

KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 

Último (20)

KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 

Automatic trash can using Arduino

  • 1. By : Haris Panca Muhammad Efantama Kenanga Ayu Nirmala
  • 2. This idea we got when we pay attention to our surroundings clean, some people less lazy throw away trash in its place amongst other things because, if we have to throw away trash pressing or touching the dumpster, therefore we have an idea to make project of the instrumentation, entitled "Trash" that can open and close automatically so that people will dump need not be touching or tapping the dumpster.
  • 3. To bring back the community will want to dispose of the waste in place, some of the trash made as attractive as possible so that the public are interested to dump garbage at the venue. One of them, namely the trash with an automated system where to open the dumpster, users do not need to touch the dumpster. Users only need to stand in front of the Ultrasonic sensors on the front, then the bin will open automatically. In addition the bin is equipped with LEDs so that when the bin is open green light will turn on and when the trash can close the light is red.
  • 5.  Arduino Uno  Sensor Ultrasonik  Servo TowerPro SG90  Buzzer  Resistor 220Ohm  LED (Red and Blue)  PCB  Acrylic  Cable (M to M, M to F, and F to F)  Trash Bin
  • 9.
  • 10.
  • 12.
  • 13. #include <Servo.h> Servo myservo; #define buzzer 3 int sound; #define trigPin 11 #define echoPin 10 #define led 6 #define led2 4 void setup() { Serial.begin (9600); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(buzzer, OUTPUT); pinMode (led, OUTPUT); pinMode(led2, OUTPUT); myservo.attach(9); } void loop() { long duration, distance; digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance = (duration/1) / 29.1; if (distance >=0 && distance <= 20) { myservo.write(160); tone(buzzer, 3000,150); digitalWrite(led, LOW); digitalWrite(led2, HIGH); } else if (distance > 20 || distance < 0){ myservo.write(0); noTone(buzzer); Serial.println("Jarak diluar jangkauan!"); digitalWrite(led, HIGH); digitalWrite(led2, LOW); } else { Serial.print(distance); Serial.println(" cm"); } delay(250); }