 void loop(void)
 {
 
+  static long next_millis = millis()+1000; 
+
  //block interrupts while retreiving the temperature values.
  noInterrupts();
  int16_t adc_copy=adc_value;

  */
  //setup PWM and interrupts. These use the 16 bit timer1
  #define PWM_PERIOD_US 20000 //20000us = 20ms = 50Hz PWM frequency. We have to go slow enough to allow time for sampling the ADC during the PWM off time
  #define PWM_PERIOD_MS (PWM_PERIOD_US/1000)  
  Timer1.initialize(PWM_PERIOD_US);  
  Timer1.pwm(LPINB, 1023-61); //we need 1.2 ms to sample the ADC. assuming 860 SPS setting
  Timer1.pwm(LPINA, 2); //100% = 1023
  delay(PWM_PERIOD_MS); //make sure both PWM's have run at least one full period before enabling interrupts 


    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.setCursor(0,0);
float tempfloat = (float)adc_copy * 0.1901 + 1.6192+(float)temperature_copy;

  display.print(temperature_copy);
 display.print(" ");
 display.print(adc_copy);
  display.print(" ");
   display.print(tempfloat);

display.display();
 Serial.print(millis());
 Serial.print(" ");
 Serial.print(adc_copy);
 Serial.print(" ");
 Serial.println(tempfloat);
 //delay(1000); 

while (millis()<next_millis);

next_millis+=1000;


}


