int trig(12);
int echo(11);
int a(10);
int b(7);
//int buzzer(5);
int time;
int distance;
void setup() 
{
  Serial.begin(9600);
  pinMode(trig, OUTPUT);
  pinMode(echo, INPUT);
  pinMode(a, OUTPUT);
  pinMode(b, OUTPUT);
  //pinMode(buzzer, OUTPUT);
  // put your setup code here, to run once:

}

void loop() {
  digitalWrite(trig, LOW);
  delayMicroseconds(2);
  digitalWrite(trig, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig, LOW);
  time = pulseIn(echo, HIGH);
  distance = (0.034*time)/2;
  Serial.print("Distance = ");
  Serial.println(distance);
  if (distance<=100 && distance>=51){
    digitalWrite(a, LOW);
    digitalWrite(b, HIGH);
    delay(500);
  }
  else if (distance<=50){
    digitalWrite(a, HIGH);
    //digitalWrite(buzzer, HIGH);
    digitalWrite(b, LOW);
    delay(500);
  }
  else
  {
    digitalWrite(a, LOW);
    digitalWrite(b, LOW);
  }
}