 void doUpdate() {
 	int newLedLevel;
 	// read the value from the sensor:
-	sensorValue = readSensor();
+	sensorValue = readSensor(SENSOR_PIN, MIN_LEVEL, MAX_LEVEL);
 
-	// since the sensor values are reversed (bigger value is dry and smaller value is moist)
-	// we should reverse the led values at this point
-	newLedLevel = map(sensorValue, MIN_LEVEL, MAX_LEVEL, ledArraySize, 1);
+	// sensor values are reversed (bigger value is dry and smaller value is moist)
+	newLedLevel = map(sensorValue, MIN_LEVEL, MAX_LEVEL, 255, 1);
 
 	// update if the value changes
 	if (ledLevel != newLedLevel) {

	average = (int)(sum/50.0);

	// limit sensor reading between min & max calibration values
	average = min(average, MAX_LEVEL);	// min: the smaller of two numbers
	average = max(average, MIN_LEVEL);	// max: the bigger of two numbers

	return average;
}

		setLedLevel(ledLevel);
	}

}

/**
 * Ligt the LED according to given level where 0 is LED OFF and 255 green
 * @param Integer level number of leds to light up from 0 to 5
 */
void setLedLevel(int level) {
	int ledR = 0,
		ledG = 0,
		ledB = 0;

	int brightnessValue = readSensor(BRIGHTNESS_PIN, 0, 200);

	// turn off LED if level is zero
	if (level == 0) {
		FastLED.setBrightness(BRIGHTNESS_OFF);
	} else {
		if (brightnessValue > BRIGHTNESS_THRESHOLD) FastLED.setBrightness(BRIGHTNESS_MAX);
		else FastLED.setBrightness(BRIGHTNESS_MIN);
	}

	// reverse LED level so red is shown when the soil is dry and green when moist
	level = map(constrain(level, 0, MAX_LED_VALUE), 0, 255, 255, 0);

	// this changes the led color from red to yellow to green
	ledR = constrain(2 * level, 0, 255);
	ledG = constrain(2 * (255 - level), 0, 255);

	// set led color and show it to the world
	smartLed[0].setRGB(ledR, ledG, ledB);
	FastLED.show();
}

/**
 * Read moisture sensor multiple times and return the average
 * @return Integer
 */
int readSensor(int sensorPin, int min, int max) {

	int average;
	float sensorValue, sum;
	for (int i = 0; i < 50; i++) {
		sensorValue = analogRead(sensorPin);
		sum += sensorValue;
		delay(1);
	}
