   
     //to get the with 1,2,3 the needed indices we use i*2 and i*2+1
     //0 = 0,1 / 1 = 2,3 / 2 = 4,5   
-    int distance = (distanceValues[i*2] + distanceValues[i*2+1]) / 2;
+    //int distance = (distanceValues[i*2] + distanceValues[i*2+1]) / 2;
+    int distance = distanceValues[i];
+    if(distance < minDistance) {
+      if(distance == 0) {
+        distance = maxDistance; 
+      }  
+      else {
+        distance = minDistance;
+      }
+    }
     int heightStrip = NUMBER_LEDS/NUMBER_STRIPS;
     
     //how many of the leds of one strip should be switched on

#include <Adafruit_NeoPixel.h>
#include <Servo.h> 
#include <avr/power.h>

//Hardware constants
#define PIN_STRIP 6
#define PIN_SENSOR 7
#define PIN_SERVO 8

#define NUMBER_LEDS 48
#define NUMBER_STRIPS 3

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMBER_LEDS, PIN_STRIP, NEO_GRB + NEO_KHZ800);
Servo servo;

//Servo variables
int servoPos = 0;
int servoSteps = 6;
int servoMinAngle = 0;
int servoMaxAngle = 90;
int servoStepAngle = (servoMaxAngle-servoMinAngle)/(servoSteps-1);
int servoMSPerDegree = 5;

//Max and Min value for the distance sensor
float maxDistance = 500;
float minDistance = 10;

//Store of the measured distances of each servo step
int distanceValues[6];

void setup() {  
  //Init distance store to far away
  for(int i=0; i<servoSteps; i+=1){
    distanceValues[i] = 0;
  }
  
  //For console output
  Serial.begin(9600);

  
    //to get the with 1,2,3 the needed indices we use i*2 and i*2+1
    //0 = 0,1 / 1 = 2,3 / 2 = 4,5   
    //int distance = (distanceValues[i*2] + distanceValues[i*2+1]) / 2;  
    int distance = distanceValues[i];
    if(distance < minDistance) {
      if(distance == 0) {
        distance = maxDistance; 
      }  
      else {
        distance = minDistance;
      }
    }
    //Serial.println(distance);
    int heightStrip = NUMBER_LEDS/NUMBER_STRIPS;
    
    //how many of the leds of one strip should be switched on
