Data logging with SD Shield vs. Data Logging Shield

Hello, I am trying to write a basic data logging program where if a switch is flipped, a timer starts (from 0 and going up in 1 sec increments) and then if another input goes high, that is recorded alongside the time it occurred at. I’m having 2 issues. One, I am new to Arduino and didn’t even know there was a data logging shield and already purchased an SD shield so it doesn’t have the RTC Real Time clock on it. Is there any way to make this SD shield work for data logging where it accurately keeps track of the timer without the RTC? And two, my current program doesn’t update the pin values once the program starts (i.e. I open Serial monitor and a switch reads 0, then I flip the switch and it still reads 0, but if I close the Serial Monitor and reopen it then the switch reads 1). I can’t figure out how to get it to continuously update…I think something from my loop should be in my setup or vice versa. The current code doesn’t even have a timer in it because I tried a basic counter with a 1 sec delay but it doesn’t work, so right now I have it saying that if I hit the START switch then it will start displaying 0’s and then log when a TRIP occurs. Any help would be greatly appreciated, thank you!

#include <SPI.h>
#include <SD.h>

const int chipSelect = 8;      //SD shield CS pin for Arduino Uno
const int STARTpin = 2;
const int TRIPpin = 4 ;

int START=digitalRead(STARTpin); 
int TRIP=digitalRead(TRIPpin);

File dataFile;

void setup()
 // Open serial communications and wait for port to open:
  Serial.print("Initializing SD card...");
  pinMode(10, OUTPUT);    //default pin 10 must be set to output
  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    while (1) ;
  Serial.println("card initialized.");
  // Open up the file we're going to log to!
  dataFile ="datalog.txt", FILE_WRITE);
  if (! dataFile) {
    Serial.println("error opening datalog.txt");
    // Wait forever since we cant write data
    while (1) ;

void loop()
  // make a string for assembling the data to log:
  String dataString = "0";

    dataString += String(START);


  // print to the serial port too:

  // If you want to speed up the system, remove the call to flush() and it
  // will save the file only every 512 bytes - every time a sector on the 
  // SD card is filled with data.
  // Take 1 measurement every 500 milliseconds

Just figured out why the pins aren't continuously updating, apparently the digitalRead lines (for reading the START and TRIP pins) needed to be in my loop. So now only issue is that timer!

Is there any way to make this SD shield work for data logging where it accurately keeps track of the timer without the RTC?

You could send the data to Excel, using PLX-DAQ, or even a simple terminal programme like RealTerm. The data can then be time-stamped therein using the PC clock. In this event the SD shield may be redundant too.

It should also be possible to get the time from the PC’s clock and use it in Arduino

The principle reason for having an RTC is for backup purposes, or when Arduino has to stand alone. You also have to make up your mind about whether you really need the time, or just need to know the relative difference between between the readings.

You can use a software clock. The principle difference between a software clock and an RTC module is $2 and a battery. Most people pay the $2, and get the battery.