Translate

Mobil Parkir Otomatis (Self-Car Parking System) Menggunakan ANDROID dan Arduino

Mobil Parkir Otomatis (Self-Car Parking System) Menggunakan ANDROID dan Arduino


         Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah sistem mobil yang mana mobil tersebut bisa parkir otomatis, jadi mobil bisa menuju ke parkiran dan menempatkan mobil ke halaman parkir. handphone android digunakan untuk menentukan lokasi parkir yang diinginkan. mikrokontroller yang dipakai adalah Arduino UNO dan motor driver yang digunakan untuk kendali roda adalah L298. sebagai pengaman arus dan tegangan dipakai UBEC 3A agar arus tidak masuk ke Arduino secara berlebih saat motor dc berjalan. untuk deteksi jarak saat mundur digunakan sensor jarak SRF04. terdapat sensor photodioda yang akan mendeteksi lokasi parkir 1 dan 2, jika terdeteksi garis hitam pertama, artinya disitulah tempat parkir 1, jika terdeteksi garis hitam kedua, artinya disitulah parkiran ke 2. untuk lebih jelasnya berikut adalah program dam skema lengkapnya. 




1. Arduino UNO





2. LCD 16x2 dan I2C Modul





3. Driver Motor L298





4. Sensor Photodioda





5. UBEC 3A





6. Sensor Jarak SRF04





7. Bluetooth HC-05





8. Progam Android 






9. Program Arduino IDE

#include "Wire.h"
#include <LiquidCrystal_I2C.h>

#define trigPin 3
#define echoPin 4

const int pwm = 2;
int accelero;
int f = 1;

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

void setup() {
  lcd.begin(16, 2);
  lcd.clear();
  lcd.noCursor();
 
  Serial.begin(9600);
  Serial.setTimeout(5);
 
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
 
  pinMode(6, OUTPUT);
  pinMode(pwm, OUTPUT);

 
}

void loop() {

/* 
      int dataadc0 = analogRead(A0);
     int dataadc1 = analogRead(A1);
      int dataadc2 = analogRead(A2);
       int dataadc3 = analogRead(A3);
 
  lcd.setCursor(0, 0);
  lcd.print(dataadc0);
  lcd.print(" ");
  lcd.print(dataadc1);
 
  lcd.setCursor(0, 1);
  lcd.print(dataadc2);
  lcd.print(" ");
  lcd.print(dataadc3);
 
  delay(2000);
  lcd.clear();
*/ 

  if (Serial.available() > 0)
{
  accelero = Serial.parseInt();
  Serial.println(accelero);

 if (accelero == 100)
 {

  lcd.setCursor(0, 0);
  lcd.print("PARKIR SATU ");
  delay(3000);
  lcd.clear();
 
  analogWrite(pwm,128);
  analogWrite(6,150);

  for (int i=0; i <= 40; i++){
   
    int dataadc0 = analogRead(A0);
     int dataadc1 = analogRead(A1);
      int dataadc2 = analogRead(A2);
       int dataadc3 = analogRead(A3);
      
  //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
  if((dataadc0 > 1000) && (dataadc1 > 1000) && (dataadc2 > 1000) && (dataadc3 > 1000)) {
  i = 39;
  }
 
   }
  
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //kiri 
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  delay(1000);
    
  for (int i=0; i <= 80; i++){
 
 
  //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }

  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //KANAN
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
 
 
  for (int i=0; i <= 80; i++){
 

//mundur 
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW);   
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }

  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //kiri 
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  delay(1000);
 
 
  for (int i=0; i <= 30; i++){

  //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }
  
    digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //KANAN
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
 
 
while(1){
//mundur 
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW);   
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
  long duration, distance;
  digitalWrite(trigPin, LOW);  // Added this line
  delayMicroseconds(2); // Added this line
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10); // Added this line
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;

  lcd.setCursor(0, 0);
  lcd.print("jarak ");
  lcd.setCursor(0, 1);
  lcd.print(distance);

 if(distance < 7){

   while(1){
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);   
     loop();
   }
  
 }
 
}  

}



//==================================================================



 if (accelero == 300)
{

   analogWrite(pwm,128);
  analogWrite(6,150);
 
  lcd.setCursor(0, 0);
  lcd.print("PARKIR TIGA ");
  delay(3000);
  lcd.clear();
 
   //kiri 
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  delay(1000);

  for (int i=0; i <= 100; i++){
   
  //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
    digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
 
   }
  
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //KANAN
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
 
    
  for (int i=0; i <= 80; i++){
 

  //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }

  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
   //kiri 
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  delay(1000);
  
 
  for (int i=0; i <= 80; i++){
 

//mundur 
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW);   
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }

  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //KANAN
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
 
 
  for (int i=0; i <= 80; i++){

  //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }
  
    digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
   //kiri 
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  delay(1000);
 
 
while(1){
//mundur 
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW);   
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
  long duration, distance;
  digitalWrite(trigPin, LOW);  // Added this line
  delayMicroseconds(2); // Added this line
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10); // Added this line
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;

  lcd.setCursor(0, 0);
  lcd.print("jarak ");
  lcd.setCursor(0, 1);
  lcd.print(distance);

 if(distance < 7){

   while(1){
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);   
    loop();
   }
  
 }
 
}  

}


//=================================================================

 if (accelero == 200)
 {

  
  lcd.setCursor(0, 0);
  lcd.print("PARKIR DUA ");
  delay(3000);
  lcd.clear();

  analogWrite(pwm,128);
  analogWrite(6,150);

  for (int i=0; i <= 100; i++){
   
    int dataadc0 = analogRead(A0);
     int dataadc1 = analogRead(A1);
      int dataadc2 = analogRead(A2);
       int dataadc3 = analogRead(A3);
      
  if((dataadc0 > 1000) && (dataadc1 > 1000) && (dataadc2 > 1000) && (dataadc3 > 1000)&&(f == 1)) {
  f = 2;
 
  for (int i=0; i <= 10; i++){
    //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
      int dataadc0 = analogRead(A0);
     int dataadc1 = analogRead(A1);
      int dataadc2 = analogRead(A2);
       int dataadc3 = analogRead(A3);
 
  }
 
  
  }
 
      dataadc0 = analogRead(A0);
      dataadc1 = analogRead(A1);
      dataadc2 = analogRead(A2);
      dataadc3 = analogRead(A3);
 
 
  if((dataadc0 > 1000) && (dataadc1 > 1000) && (dataadc2 > 1000) && (dataadc3 > 1000)&&(f == 2)) {
  i = 99;
  f = 1;
  }
      
      
  //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }
  
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //kiri 
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  delay(1000);
    
  for (int i=0; i <= 50; i++){
 

  //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }

  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //KANAN
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
 
 
  for (int i=0; i <= 50; i++){
 

//mundur 
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW);   
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }

  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //kiri 
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  delay(1000);
 
 
  for (int i=0; i <= 30; i++){

  //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }
  
    digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //KANAN
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
 
 
while(1){
//mundur 
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW);   
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
  long duration, distance;
  digitalWrite(trigPin, LOW);  // Added this line
  delayMicroseconds(2); // Added this line
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10); // Added this line
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;

  lcd.setCursor(0, 0);
  lcd.print("jarak ");
  lcd.setCursor(0, 1);
  lcd.print(distance);

 if(distance < 7){

   while(1){
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);   
     loop();
   }
  
 }
 
}  
 

 
}





//=============================================================================


 if (accelero == 400)
 {


  analogWrite(pwm,128);
  analogWrite(6,150);
 
  lcd.setCursor(0, 0);
  lcd.print("KELUAR 1 ");
  delay(3000);
  lcd.clear();
 
   //kiri 
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  delay(1000);

  for (int i=0; i <= 80; i++){
   
  //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }
  
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //KANAN
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
 
    
  for (int i=0; i <= 50; i++){
 

  //MUNDUR
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }

  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
   //kiri 
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  delay(1000);
  
 
  for (int i=0; i <= 80; i++){
 

//maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH);   
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }

  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //kanan
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
 
 
  for (int i=0; i <= 30; i++){

  //mundur 
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }
  
  
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //kiri
  digitalWrite(10, LOW);
  digitalWrite(11, LOW);
 
 
  for (int i=0; i <= 80; i++){

  //maju
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }
  

 }


//=======================================================================


  if (accelero == 500)
 {

  

  analogWrite(pwm,128);
  analogWrite(6,150);
 
  lcd.setCursor(0, 0);
  lcd.print("KELUAR 2 ");
  delay(3000);
  lcd.clear();
 
   //kiri 
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  delay(1000);

  for (int i=0; i <= 80; i++){
   
  //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }
  
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //KANAN
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
 
    
  for (int i=0; i <= 50; i++){
 

  //MUNDUR
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }

  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
   //kiri 
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  delay(1000);
  
 
  for (int i=0; i <= 80; i++){
 

//maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH);   
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }
 
    loop();
    
 }

//=========================================================================

  if (accelero == 600)
 {


  analogWrite(pwm,128);
  analogWrite(6,150);
 
  lcd.setCursor(0, 0);
  lcd.print("KELUAR 3 ");
  delay(3000);
  lcd.clear();
 
   //kanan 
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
  delay(1000);

  for (int i=0; i <= 80; i++){
   
  //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }
  
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //kiri
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
 
    
  for (int i=0; i <= 50; i++){
 

  //MUNDUR
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }

  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
   //kanan 
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
  delay(1000);
  
 
  for (int i=0; i <= 80; i++){
 

//maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH);   
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }

  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //kiri
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
 
 
  for (int i=0; i <= 30; i++){

  //mundur 
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }
  
  
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
    //lurus
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
  delay(1000);
 
  //lurus
  digitalWrite(10, LOW);
  digitalWrite(11, LOW);
 
 
  for (int i=0; i <= 80; i++){

  //maju
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }
  
 
  
 }



}

 
}




10. VIDEO HASILNYA














No comments:

Post a Comment