   pinMode(PWMB, OUTPUT);
   pinMode(BIN1, OUTPUT);
   pinMode(BIN2, OUTPUT);
-  past = 'f';
+
+  //initialising values
+  past = 'f'; //set default move to forward
   count = 0;
   iter = 0;
   threshold = analogRead(backleft) - 200;

#include <SharpDistSensor.h>

// Analog pin to which the sensor is connected
const byte sensorPin = A0;
const byte sensorPin2 = A1;
const byte backleft = A6;
const byte backright = A7;
const byte frontright = A2;
const byte frontleft = A3;

// Window size of the median filter (odd number, 1 = no filtering)
const byte mediumFilterWindowSize = 5;
unsigned int distance;
unsigned int distance2;

// Create an object instance of the SharpDistSensor class
SharpDistSensor sensor(sensorPin, mediumFilterWindowSize);
SharpDistSensor sensor2(sensorPin2, mediumFilterWindowSize);
int STBY = 10; //standby

//Motor A
int PWMA = 3; //Speed control
int AIN1 = 9; //Direction
int AIN2 = 8; //Direction

//Motor B
int PWMB = 5; //Speed control
int BIN1 = 11; //Direction
int BIN2 = 12; //Direction
char past;
int count;
int threshold;
short iter;
void setup() {
  Serial.begin(9600);

}

void move(int motor, int speed, int direction){
  //Move specific motor at speed and direction
  //motor: 1 for right, 2 for left
  //speed: 0 is off, and 255 is full speed
  //direction: 0 clockwise, 1 counter-clockwise
  
  digitalWrite(STBY, HIGH); //disable standby
  
  boolean inPin1 = LOW;
  boolean inPin2 = HIGH;
  
  if(direction == 1){
    inPin1 = HIGH;
    inPin2 = LOW;
  }
  
  if(motor == 1){
    digitalWrite(AIN1, inPin1);
    digitalWrite(AIN2, inPin2);
    analogWrite(PWMA, speed);
  } else {
    digitalWrite(BIN1, inPin1);
    digitalWrite(BIN2, inPin2);
    analogWrite(PWMB, speed);
  }
}

void stop(){
  //enable standby
  digitalWrite(STBY, LOW);
}
