int trig_pin = 13;
int echo_pin = 12;

int pins[] = {2,3,4,5,6,7,8,9,10,11};

int sm=300;

long duration;
float distance;

void setup() {
  pinMode(trig_pin, OUTPUT);
  pinMode(echo_pin, INPUT);

  for(int i=0; i<10; i++) {
    pinMode(pins[i], OUTPUT);
  }

  Serial.begin(9600);
}

void loop() {
  digitalWrite(trig_pin, LOW);
  delayMicroseconds(2);

  digitalWrite(trig_pin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig_pin, LOW);

  duration = pulseIn(echo_pin, HIGH);
  distance = 0.0344 * duration / 2;

  // Serial.print("Height of person: ");
  // Serial.println(sm - distance);
  // Serial.println(distance);
  // digitalWrite(led_pin, distance < 200);

  int level = map(distance, 2, 400, 0, 10);
  Serial.println(distance);

  for(int i=0; i <= 10; i++){
    digitalWrite(pins[i], i< level ? HIGH : LOW);
  }
}

// v = 340 m/s or 346 m/s