#include  
#include 
#define TRIG_PIN A4 // Pin A4 on the Arduino Sensor Shield
#define ECHO_PIN A5 // Pin A5 on the Arduino Sensor Shield
#define MAX_DISTANCE 200 // sets maximum useable sensor measuring distance to 200cm
#define MAX_SPEED 180 // sets speed of DC traction motors to 180/256 or about 70% of full speed - to keep power drain down.
#define MAX_SPEED_OFFSET 20 // this sets offset to allow for differences between the DC traction motors
#define COLL_DIST 10 // sets distance at which robot stops and reverses to 10cm
#define TURN_DIST COLL_DIST+25 // sets distance at which robot veers away from object (not reverse) to 25cm (10+15)
NewPing sonar(TRIG_PIN, ECHO_PIN, MAX_DISTANCE); // sets up sensor library to use the correct pins to measure distance.
//Assign digital pins used to drive the motors
int ENA=5;//connected to Arduino's port 5(output pwm)
int IN1=2;//connected to Arduino's port 2
int IN2=3;//connected to Arduino's port 3
int ENB=6;//connected to Arduino's port 6(output pwm)
int IN3=4;//connected to Arduino's port 4
int IN4=7;//connected to Arduino's port 7
Servo myservo; // create servo object to control a servo 
int pos = 0; // this sets up variables for use in the sketch (code) 
int curDist = 0; //Current distance
int maxDist = 0; //Maximum distance from a sweep of pings
int maxPos = 0; //Angle at which maximum distance was detected.
String motorSet = "";
int speedSet = 0;
//---- SETUP LOOP ------
void setup() {
//Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results
 pinMode(ENA,OUTPUT);//output
 pinMode(ENB,OUTPUT);
 pinMode(IN1,OUTPUT);
 pinMode(IN2,OUTPUT);
 pinMode(IN3,OUTPUT);
 pinMode(IN4,OUTPUT);
 digitalWrite(ENA,LOW);
 digitalWrite(ENB,LOW);//stop driving
 digitalWrite(IN1,HIGH); 
 digitalWrite(IN2,LOW);//setting motorA's direction
 digitalWrite(IN3,LOW);
 digitalWrite(IN4,HIGH);//setting motorB's direction
 myservo.attach(9); // attaches the servo on pin 9
 myservo.write(90); // tells the servo to position at 90-degrees ie. facing forward.
 delay(2000); // delay for two seconds
 lookAround(); //identify furthest object and direction
 setCourse(); //off we go.
}
//------------------------