Tong Sampah Otomatis Berbasis Arduino

Project Untuk Kelompok 5




Komponen yang dibutuhkan :
  • Arduino (Versi apapun) >> 1 Buah.
  • Sensor Jarak (Ultrasonic) >> 1 Buah.
  • Servo >> 1 Buah.
  • Buzzer >> 1 Buah.
  • Kabel >> Seperlunya.

Wiring :

Source Code :

       /*  
        * Generated Code by Kang Kamal  
        * kangkamal.blogspot.com  
        */  
       #include <NewPing.h>  
       #include <Servo.h>  
       #define TRIGGER_PIN 12 // Arduino pin tied to trigger pin on the ultrasonic sensor.  
       #define ECHO_PIN   11 // Arduino pin tied to echo pin on the ultrasonic sensor.  
       #define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.  
       NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.  
       Servo myservo;  
       int buzzer = 6;  
       int jarak = 0;  
       void setup() {  
        // put your setup code here, to run once:  
        Serial.begin(9600);  
        pinMode(buzzer, OUTPUT);  
        digitalWrite(buzzer, LOW); //Set default buzzer >> OFF  
        myservo.attach(10); //Pin Servo  
        myservo.write(0); //Derajat servo di set ke 0  
       }  
       void loop() {  
        // put your main code here, to run repeatedly:  
        delay(20); //Diberikan jeda untuk membaca data dari sensor ultrasonic  
        jarak = sonar.ping_cm();  
        Serial.print("Jarak : ");  
        Serial.println(jarak);  
        if(jarak < 20){  
         digitalWrite(buzzer, HIGH); //Buzzer dinyalakan tanda ada objek mendekat  
         myservo.write(90); //Derajat servo di set ke 90  
         delay(2000);  
         myservo.write(0); //Derajat servo di set ke 0  
         digitalWrite(buzzer, LOW); //Buzzer dimatikan  
        }  
       }  
      

      comment 4 comments:

      Unknown on November 22, 2018 at 1:06 PM said...

      bazer dsini fungsinya untuk apa bang ?

      Febrian Maulana on January 11, 2019 at 5:25 PM said...

      Cara rangkainya gimaa

      Unknown on January 12, 2019 at 9:22 AM said...

      Kok eror bg

      mrwahyu212 on December 20, 2020 at 2:55 PM said...

      Terima kasih tutorialnya. Alat berjalan dengan sempurna.. :D

      Post a Comment

      CNC Tutorial Cetak si SAM Assistant

       
      © All 4 You... | Design by Blog template in collaboration with Concert Tickets, and Menopause symptoms
      Powered by Blogger