 
 void loop() {
     // read sensor data
-    plant1_value = analogRead(A0);
-    plant2_value = analogRead(A1);
-    plant3_value = analogRead(A2);
-    voltage_value = analogRead(A3);
-    light_value = analogRead(A4);
-    temperature_value = analogRead(A5);
+    plant1_value = analogRead(PLANT_SENSOR_1);
+    plant2_value = analogRead(PLANT_SENSOR_2);
+    plant3_value = analogRead(PLANT_SENSOR_3);
+    voltage_value = get_voltage_value();
+    light_value = analogRead(LIGHT_SENSOR);
+    temperature_value = get_temperature_value();
 
-    // voltage probing (takes 2s)
-    long sum=0;
-    for(int i=0;i<1000;i++)
-    {  
-        sum=voltage_value+sum;
-        voltage_value=analogRead(A3);
-        delay(2);
-    }   
-    sum=sum/1000;
-
-    // voltage mapping
-    battery_value = 10*sum*4980/(1023.00*1000) * 12.96/14.07; // voltmeter used to determine last factor
-
-    // set led bar accordingly to solar value
-    led_bar_value = round((battery_value-10.0)/4.0*10); // min: 10V max: 14V
-    led_bar_value = max(min(led_bar_value,10),0); // make sure led_bar_value is in range 0-10
-    led_bar.set_LED_Range(1,led_bar_value);
-
-    // temperature mapping to celsius
-    resistance=(float)(1023-temperature_value)*10000/temperature_value;
-    temperature=1/(log(resistance/10000)/B+1/298.15)-273.15;
-
+    set_led_bar();
     
     if (Serial.available() > 0) { // check if serial input is available
         // turn status led on

            }
        }
    }
}
#include "LED_Bar.h"
#include <math.h>

// analog sensor mapping
#define PLANT_SENSOR_1 A0
#define PLANT_SENSOR_2 A1
#define PLANT_SENSOR_3 A2
#define VOLTAGE_SENSOR A3
#define LIGHT_SENSOR A4
#define TEMPERATURE_SENSOR A5

#define THERMISTOR_VALUE 3975 //B value of the thermistor

LED_Bar led_bar;

int led_pin = 3;
int relay_pin = 4;
