How to execute a function for "t" time without delay + using external interrupt

Just FYI:

#include <Time.h>
#include <TimeAlarms.h>

void setup() {
  Serial.begin(9600);
  Serial.println("Waiting for command");
}
 
AlarmID_t temptimer;
  
void loop() {
       
  // this is where the "polling" occurs
  if(Serial.available()){
    char ch=Serial.read();
    switch(ch)
    {
      case '1':
      // start recording?
      temptimer = Alarm.timerRepeat(1, Tempfunct);
      break;
     
      case '2':
      // stop recording?
      Alarm.disable(temptimer);
      break;
           
      default:
      Serial.print(ch);
      Serial.println(" : unknown command!");
    }   
  }
}

// function to be called
void Tempfunct() {
   // do whatever reading
   Serial.println(analogRead(A0));
}

This is perhaps kinda heavy for what you appear to be doing (should use the "blink without delay" method), but just wanted to followup.

Also, TimeAlarms.cpp needs to be updated for Arduino 1.0.

Replace:#include <WProgram.h>

With:

#if ARDUINO >= 100
#include <Arduino.h> 
#else
#include <WProgram.h> 
#endif