 
 void loop() {
   if (sample) {
-    ref = readTemp();
+    int tt = readTemp();
     int tv = readVol();
-    if (ref > temp)
-      temp = ref;
+    if (tt > temp)
+      temp = tt;
     if (tv > vol)
       vol = tv;
     cycle++;

  i2c_init(); //Initialise the i2c bus
  PORTC = (1 << PORTC4) | (1 << PORTC5);//enable pullups
  
  for (int i = 0; i < 10; i++) {
    ref += readTemp();
    delay(1000);
  }
  ref /= 10;

  display.write((int) ref / 10);
  display.write((int) ref % 10);

  }
}

float mlxRead(byte loc){
  int dev = 0x5A<<1;
  int data_low = 0;
  int data_high = 0;
  int pec = 0;
  
  i2c_start_wait(dev+I2C_WRITE);
  i2c_write(loc);
  
  // read
  i2c_rep_start(dev+I2C_READ);
