Make motors stop when there is no avaible area

Hello guys. First of all i am sorry for my english if i had any mistakes. I am working on 4wd autonomous parking car by using arduino. i have 4 sensors(2 of them on left side, one on the front and one of the back). Car is properly parking if i did put boxes properly for scenerio. But i want to make motors stop if there is no avaible area for my car.

#include <AFMotor.h>
 AF_DCMotor Left_Front_Motor(4);
 AF_DCMotor Right_Front_Motor(3);
 AF_DCMotor Left_Rear_Motor(1);
 AF_DCMotor Right_Rear_Motor(2);
#include <Ultrasonic.h>

Ultrasonic BackSensor(40,41),SensorLeftRear(38,39),SensorLeftFront(36,37),SensorFront(34,35);
// ultrasonik sensörlerin tanımlamaları


#define Left 0 //Left yön komutu 
#define Right 1 //Right yön komutu
#define Forward 2 //Forward yön komutu
#define Backward 3 //Backward yön komutu
#define Width_of_car 15 //Arabanın genişliği (cm)
#define Width_of_car1 28 //Arabanın uzunluğu (cm)

byte Parking_Situation = 0; 
int IR_pin = 21; 
volatile int val;

int count = 0;
int Curent_Status = 0;
int Previous_Status = 0;

void Number(int Count_it)
{
  for (int i = 0 ; i <= Count_it; i+1)
  {
   val = digitalRead(IR_pin); 
if (val == LOW) { 

Curent_Status = 0;
}
else {

Curent_Status = 1;
}


if(Curent_Status != Previous_Status)
{
if(Curent_Status == 1)
{
count = count + 1;
Serial.println(count);
i = i+1;
}
else 
{ 
  i = i ;
}

Previous_Status = Curent_Status;

}
if (i == Count_it)
{
  
  Left_Front_Motor.run(RELEASE);
  Right_Front_Motor.run(RELEASE);
  Left_Rear_Motor.run(RELEASE);
  Right_Rear_Motor.run(RELEASE);
 

}


  }

}





void motor_pinSetup()
{

 Left_Front_Motor.run(RELEASE);
  Right_Front_Motor.run(RELEASE);
  Left_Rear_Motor.run(RELEASE);
  Right_Rear_Motor.run(RELEASE);
}






// Hareket fonksiyonları
    void Robot_Move(byte motor, byte spd)
{
  if (motor == Forward)
  {
     Left_Front_Motor.setSpeed(spd);
   Right_Front_Motor.setSpeed(spd);
   Left_Rear_Motor.setSpeed(spd);
   Right_Rear_Motor.setSpeed(spd);
  Left_Front_Motor.run(FORWARD);
  Right_Front_Motor.run(FORWARD);
  Left_Rear_Motor.run(FORWARD);
  Right_Rear_Motor.run(FORWARD);

  }
    if (motor == Backward)
  {
     Left_Front_Motor.setSpeed(spd);
   Right_Front_Motor.setSpeed(spd);
   Left_Rear_Motor.setSpeed(spd);
   Right_Rear_Motor.setSpeed(spd);
  Left_Front_Motor.run(BACKWARD);
  Right_Front_Motor.run(BACKWARD);
  Left_Rear_Motor.run(BACKWARD);
  Right_Rear_Motor.run(BACKWARD);

  }
    if (motor == Left)
  {
     Left_Front_Motor.setSpeed(spd);
   Right_Front_Motor.setSpeed(spd);
   Left_Rear_Motor.setSpeed(spd);
   Right_Rear_Motor.setSpeed(spd);
  Left_Front_Motor.run(BACKWARD);
  Right_Front_Motor.run(FORWARD);
  Left_Rear_Motor.run(BACKWARD);
  Right_Rear_Motor.run(FORWARD);

  }

    if (motor == Right)
  {
     Left_Front_Motor.setSpeed(spd);
   Right_Front_Motor.setSpeed(spd);
   Left_Rear_Motor.setSpeed(spd);
   Right_Rear_Motor.setSpeed(spd);
  Left_Front_Motor.run(FORWARD);
  Right_Front_Motor.run(BACKWARD);
  Left_Rear_Motor.run(FORWARD);
  Right_Rear_Motor.run(BACKWARD);

  }
    
}   


void Robot_Stop()
{


   Left_Front_Motor.run(RELEASE);
  Right_Front_Motor.run(RELEASE);
  Left_Rear_Motor.run(RELEASE);
  Right_Rear_Motor.run(RELEASE);
}






// Park yeri araması
bool ParkingLot_Control()
{

 long front_Sensor  = SensorFront.Ranging(CM);
long Right_Sensor = SensorLeftFront.Ranging(CM);
long Right_back_Sensor   =SensorLeftRear.Ranging(CM);

  if( (Right_Sensor <= Width_of_car)&&(Right_back_Sensor <= Width_of_car)&&(Parking_Situation == 0))
     {
       Robot_Move(Forward, 100); 
       Parking_Situation = 1; Serial.println(Parking_Situation);
     }

  if((Right_Sensor > Width_of_car)&&(Right_Sensor < Width_of_car1)&&(Right_back_Sensor > Width_of_car)&&(Right_back_Sensor < Width_of_car1)&&(Parking_Situation == 1))
     {
 Robot_Move(Forward, 100);  
       Parking_Situation = 2;Serial.println(Parking_Situation);
     }

       if((Right_Sensor >= Width_of_car1)&&(Right_back_Sensor >= Width_of_car1)&&(Parking_Situation == 1))
     { 
      /* Dik Park Etme Kararı */
 Robot_Stop() ;
 delay(500);
       Parking_Situation = 10;Serial.println(Parking_Situation);
     }
     else{
      Robot_Stop(); /* Dik park edicek yer yoksa not avaible */
      }
 
  if((Right_Sensor <= Width_of_car)&&(Right_back_Sensor <= Width_of_car)&&(Parking_Situation == 2))
     {
/* Paralel Park Etme Kararı */
       Parking_Situation = 3;   Serial.println(Parking_Situation);
    } 
    else
    {
      Robot_Stop();  /*Eger parallel park edeck kadar alan yoksa araba dur */   
  }
    
   
    return Parking_Situation;  
}

void Find_Park()
{
 ParkingLot_Control();
if(Parking_Situation == 3 )
{
   Robot_Stop();Serial.println(Parking_Situation);
   delay(400);
 Parking_Situation = 4;
}
if(Parking_Situation == 4 )
{
  
  Robot_Move(Backward,120);
  Number(20);
   Robot_Stop();Serial.println(Parking_Situation);
     delay(500);
 Robot_Move(Right,150);
Number(12);
   Robot_Stop();
     delay(500);
   Parking_Situation = 5;
}
if(Parking_Situation == 5)
{

  Robot_Move(Backward,120);
  long back_Sensor   = BackSensor.Ranging(CM);Serial.println(back_Sensor);
 
  if(back_Sensor>0 && back_Sensor <= 13)
  {
    Robot_Stop();
    delay(400);
    Parking_Situation = 6;
  }
  return back_Sensor;
}

if(Parking_Situation == 6)
{
Robot_Move(Left,150);
   long Right_Sensor = SensorLeftFront.Ranging(CM); Serial.println(Right_Sensor);
long Right_back_Sensor   = SensorLeftRear.Ranging(CM); Serial.println(Right_back_Sensor);
  
  if(Right_Sensor == Right_back_Sensor)
  {
    Robot_Stop();
    Parking_Situation = 7;
  }
 
  return Right_Sensor,Right_back_Sensor;
}
if(Parking_Situation == 7)
{
  long front_Sensor  = SensorFront.Ranging(CM); 

  if(front_Sensor<=10)
  {
    Robot_Stop();
    Parking_Situation = 8;
  }
  else
  {
      Robot_Move(Forward,100);
  }
  return front_Sensor;
}
if (Parking_Situation ==10)
{
  
  Robot_Move(Left,180);
  Number(45);
   Robot_Stop();
   delay(500);
Parking_Situation = 7;
    
  
}

}

void setup() 
{
  Serial.begin(9600); 
  attachInterrupt(5, Number, CHANGE);
   pinMode (IR_pin, INPUT) ;
 
  motor_pinSetup();  
}


void loop() 
{
 Find_Park(); 
}

This is my code so far. If you guys help me i will be thankfull.

Can you describe in English how the system will determine that there is no available parking space ?

Arduino ile Kontrol Edilen Otonom Park Eden Araba Projesi - YouTube as you can see in this video we have the scenerio with 3 boxes for parking lot. when 2 sensors on the sides are compute the distence car make decision of one of the algoritms which is parallel or vertical parking. If the measured value is greater than the width of the car and less than the length of the car, it will operate the parallel parking system. else this car make move for vertical.

But i want makes car stops if there is no avaible parking area. for example we move the boxes narrow of the other boxes at that case i want to stop cars engine.

UKHeliBob:
Can you describe in English how the system will determine that there is no available parking space ?

CoolNg:
Arduino ile Kontrol Edilen Otonom Park Eden Araba Projesi - YouTube as you can see in this video we have the scenerio with 3 boxes for parking lot. when 2 sensors on the sides are compute the distence car make decision of one of the algoritms which is parallel or vertical parking. If the measured value is greater than the width of the car and less than the length of the car, it will operate the parallel parking system. else this car make move for vertical.

But i want makes car stops if there is no avaible parking area. for example we move the boxes narrow of the other boxes at that case i want to stop cars engine.

Well, you already have the logic figured out. Do you have it coded in your program? Stopping the motors should be readily apparent.

Paul

Paul_KD7HB:
Well, you already have the logic figured out. Do you have it coded in your program? Stopping the motors should be readily apparent.

Paul

yes i had a function for makin motors stop. but as i said i cant figure out how am i doing for stoped the car if there is no area. Because right now car will moving until the last case.