Movement related to temperature

Here is my full code. For some reason I must have your code in the wrong spot because there is no delay

// Include Libraries
#include "Arduino.h"
#include "DHT.h"
#include "Wire.h"
#include "RTClib.h"
#include "SD.h"
#include "LPS.h"

LPS ps;

// Pin Definitions
#define DHT_PIN_DATA	4
#define SDFILE_PIN_CS	53


//Global declarations
volatile long valout = 0; //valout is a 32 bit long integer that will contain the 24 bit data
volatile int n = 0; //n is a pointer for the 24 data bits in valout
word value = 0; //value will contain the binary value of the 12 bit data
char sign = '+'; //the data sign
String unit = "xxx"; //the units string
float unit_div = 1; //the scale factor for mm or in
int unit_plcs = 1; //the number of places to the right of the dp to display
float val_final = 0; //the final value to be displayed, as a floating point number which takes care of the dp position
//int period = 30000;   //10000 define timeout of 10 sec
unsigned long period = 4000;
unsigned long time_now = 0;
unsigned long time_previous = 0;
void clk();

// object initialization
File sdFile;
DHT dht(DHT_PIN_DATA);
RTC_DS3231 rtc;


// Setup the essentials for your circuit to work. It runs first every time your circuit is powered with electricity.
void setup()
{
  // Setup Serial which is useful for debugging
  // Use the Serial Monitor to view printed messages
  Serial.begin(9600);
  while (!Serial) ; // wait for serial port to connect. Needed for native USB
  Serial.println("start");
  Wire.begin();

  if (!ps.init())
  {
    Serial.println("Failed to autodetect pressure sensor!");
    while (1);
  }
  ps.enableDefault();
  pinMode(2, INPUT); //Set the pins to input; actually this is the default
  pinMode(3, INPUT);
  attachInterrupt(0, clk, FALLING); //Set the interrupt to read the data pin when the clock goes low

  //Initialize I2C device
  dht.begin();
  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }

  if (rtc.lostPower()) {
    Serial.println("RTC lost power, lets set the time!");
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtcadjust(DateTime(2014, 1, 21, 3, 0, 0));
  }
  // Set SPI SS pin to output otherwise the SD library functions will not work.
  // The SD is set to use SPI SS Arduino pin 10 as chip select(CS) by default.
  // To change the pin use SD.begin(SD_CS_PIN)
  pinMode(SDFILE_PIN_CS, OUTPUT);
  // Check if the card is present and can be initialized
  if (!SD.begin()) {
    Serial.println(F("Card failed, or not present"));
    while (1);
  }
  Serial.println(F("card initialized."));


}

// Main logic of your circuit. It defines the interaction between the components you selected. After setup, it runs over and over again, in an eternal loop.
void loop()
{
 {
   
   {
    time_now = millis();
    if(time_now - time_previous >= period)
    {
      time_previous = time_now;  //alternatively, use time_previous += period  for a more constant interval  
      Serial.println("Hello");
       
    }
   {
      
      
   
     
      // DS3231 Precision RTC Breakout
      //This will display the time and date of the RTC. see RTC.h for more functions such as rtc.hour(), rtc.month() etc.
      DateTime now = rtc.now();
      Serial.print(now.month(), DEC);
      Serial.print('/');
      Serial.print(now.day(), DEC);
      Serial.print('/');
      Serial.print(now.year(), DEC);
      Serial.print("  ");
      Serial.print(now.hour(), DEC);
      Serial.print(':');
      Serial.print(now.minute(), DEC);
      Serial.print(':');
      Serial.print(now.second(), DEC);
      Serial.println();

    }

    {
      // LPS331AP  - Barometric Pressure Sensor Breakout
      // Read Altitude from barometric sensor, note that the sensor is 1m accurate
      float pressure = ps.readPressureInchesHg();
      float altitude = ps.pressureToAltitudeFeet(pressure);
      float temperature = ps.readTemperatureF();

      Serial.print("p: ");
      Serial.print(pressure);
      Serial.print(" inHg\ta: ");
      Serial.print(altitude);
      Serial.print(" ft\tt: ");
      Serial.print(temperature);
      Serial.println(" deg F");

    }
    {
      // DHT22/11 Humidity and Temperature Sensor 
      // Reading humidity in %
      float dhtHumidity = dht.readHumidity();
      // Read temperature in Celsius, for Fahrenheit use .readTempF()
      float dhtTempC = dht.readTempF();
      Serial.print(F("Humidity: ")); Serial.print(dhtHumidity); Serial.print(F(" [%]\t"));
      Serial.print(F("Temp: ")); Serial.print(dhtTempC); Serial.println(F(" [F]"));

    }

    {
      // Micro SD Card Memory Shield Module 
      // The SD code creates a datalog.txt file for logging sensor data
      // open the file. note that only one file can be open at a time,
      // so you have to close this one before opening another.
      sdFile = SD.open("datalog.txt", FILE_WRITE);
      // if the file exists in SD card, write sensor data
      {
        //Write to file to sdCard
        if (sdFile) {
          float pressure = ps.readPressureInchesHg();
          float altitude = ps.pressureToAltitudeFeet(pressure);
          float temperature = ps.readTemperatureF();
          float dhtHumidity = dht.readHumidity();
          float dhtTempC = dht.readTempF();
          DateTime now = rtc.now();
          sdFile.print(',');
          sdFile.print(now.month(), DEC);
          sdFile.print('/');
          sdFile.print(now.day(), DEC);
          sdFile.print('/');
          sdFile.print(now.year(), DEC);
          sdFile.print(',');
          // sdFile.print(" ");
          sdFile.print(now.hour(), DEC);
          sdFile.print(':');
          sdFile.print(now.minute(), DEC);
          sdFile.print(',');
          // sdFile.print(now.second(), DEC);
          // sdFile.println();
          // sdFile.print("p: ");
          sdFile.print(pressure);
          sdFile.print(',');
          //sdFile.print(" inHg\ta: ");
          sdFile.print(',');
          sdFile.print(altitude);
          // sdFile.print(" ft\tt: ");
          sdFile.print(',');
          sdFile.print(temperature);
          //sdFile.println(" deg F");
          sdFile.print(',');
          sdFile.print(dhtHumidity);
          sdFile.print(',');
          sdFile.print(dhtTempC);
          sdFile.print(',');
          //sdFile.print(F("Humidity: ")); sdFile.print(dhtHumidity); sdFile.print(F(" [%]\t"));
          //sdFile.print(F("Temp: ")); sdFile.print(dhtTempC); sdFile.println(F(" [C]"));
          val_final = float(value) / unit_div; //scale the data as determined by the units
          sdFile.print(sign);  //print the sign for dial indicator
          sdFile.print(val_final, unit_plcs); //print the value for dial indicator
          sdFile.println(unit);  //print the unit type
          n = 0; //reset the bit pointer

          sdFile.close(); // close the file
        }
        // if the file didn't open, print an error:
        else {
          Serial.println("error opening test.txt");
        }
      }
    }
   }
    //Dial Indicator Files
    
    {

    }

    while (n != 23); //this is a critical step - loop while the pointer is not equal to 23
    //- the pointer increments during the interrupt to a total of 24 bits
    if (bitRead(valout, 20) == HIGH) //Read the sign bit (bit 20)
    {
      sign = '-';
    }
    else
    {
      sign = '+';
    }
    if (bitRead(valout, 23) == HIGH) //Read the units bit (bit 23)
    {
      unit = " in";
      unit_plcs = 4;
      unit_div = 2000;
    }
    else
    {
      unit = " mm";
      unit_plcs = 2;
      unit_div = 100;
    }
    for (int m = 0; m <= 11; m++) //Read the first 12 bits of valout to get the actual value
    {
      bitWrite(value, m, bitRead(valout, m));
    }
    val_final = float(value) / unit_div; //scale the data as determined by the units
    //delay (10000);
    Serial.print(sign);  //print the sign
    Serial.print(val_final, unit_plcs); //print the value
    Serial.println(unit);  //print the unit type
    n = 0; //reset the bit pointer
  }
}
//The interrupt handler - on the falling edge of each clock pulse, read the corresponding data bit
void clk()
{
  bitWrite(valout, n, !digitalRead(3)); //Read the data bit and write its inverse to the n bit in valout
  n = n + 1; //increment the pointer
}