 
 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

int plant1_value = 0;
int plant2_value = 0;
int plant3_value = 0;
long voltage_value = 0;
int temperature_value = 0;
int light_value = 0;

int led_bar_value = 0;
int B=3975; //B value of the thermistor

int incomingByte = 0; // for incoming serial data
int relay_delay = 0;
bool relay_delay_counting = false;

float battery_value = 0.0f;
float temperature = 0.0f;
float resistance = 0.0f;

LED_Bar led_bar;

void setup() {
    // set up pins and serial baud rate

            }
        }
    }
}

float get_temperature_value()
{
    int sensor_value;
    float resistance = 0.0f;
    sensor_value = analogRead(TEMPERATURE_SENSOR);
    // temperature mapping to celsius
    resistance=(float)(1023-sensor_value)*10000/sensor_value;
    return 1/(log(resistance/10000)/THERMISTOR_VALUE+1/298.15)-273.15;
}

float get_voltage_value()
{
    // voltage probing (takes 2s)
    long sum=0;
    for(int i=0;i<1000;i++)
    {  
        sum=voltage_value+sum;
        voltage_value=analogRead(VOLTAGE_SENSOR);
        delay(2);
    }   
    // voltage mapping
    return 10*(sum/1000)*4980/(1023.00*1000) * (12.96/14.07); // voltmeter used to determine last factor
}

void set_led_bar()
{
    // set led bar accordingly to solar value
    led_bar_value = round((voltage_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);
}