#define LDR1 32

unsigned long startTime = 0; // benyttes til at gemme meget store tal se mere i Arduino referencemanual
unsigned long endTime = 0;
unsigned long duration =0 ;
bool timerRunning = false;
int n;

void setup(){
pinMode (LDR1, INPUT);
Serial.begin(115200); // start serial monitor. 
}
void loop(){
  if (timerRunning == false && digitalRead(LDR1) == HIGH ) {
  startTime = millis();// millis(s) giver tiden i ms siden arduinoen startede. Derfor hurtigt et stort tal.
  timerRunning = true;
  }
  if (timerRunning == true && digitalRead(LDR1)== LOW ) { 
     endTime = millis();
     timerRunning = false;
     duration = endTime - startTime;
    if (duration > 1000)  { //ændres til 10 f.eks.
     Serial.print ("laser press time in milliseconds: ");
     Serial.println (duration);
     }
   }
  /*n =n+1;
  Serial.println("--------------------------------------");
  Serial.print("Gennemløb nr.");
  Serial.println(n);
  Serial.print("kører timer ?:");
  Serial.println(timerRunning);
  Serial.print("LDR1:");
  Serial.println(digitalRead(LDR1));
  Serial.print("Skuddets varighed: ");
  //Serial.println(duration);
  //delay(1000); */
}