Ich verwende folgenden Code und nen mega32 dafür:

Code:
#include <stdlib.h>
#include <inttypes.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
#include <avr/delay.h>
#include "digits.h"

#define SYSCLK 7372800UL // timer clock 8Mhz
// |= High
// &= ~ low

int x = 0; // 1/100sec
int y = 0; // 1/10 sec
int z = 0; // 1 sec
int stopp = 0; 
int running;  
int counter;
double sec = 0; 

ISR(INT0_vect){
    // Starte Messung 
    TCCR0 = 0x01;
    running = 1; 
}

ISR(INT1_vect){
    // Stopp Messung 
    TCCR0 = 0x00;
    running = 0; 
    stopp = 1; 
}


ISR(TIMER0_OVF_vect)
{    
  if (!(PINA & (1<<PINA2)))
    {
        TCCR0 = 0x01;
        running = 1;    
    }
    
  if (running == 1)   
      counter++;
  else 
      counter = 0;   

  //if (counter > 625) //7,3728MHz ohne Prescaler: (7372800/256)/288=100 --> 1/100sek Auflösung
  if (counter > 287)
  {
    x++;
    counter = 0;
    sec++; 
  }

   if (x > 9) //Zählen der einzelnen Stellen: 
   {
     x=0;
     y++;
     
   }
   if (y > 9)
   {
     y=0;
     z++;
   }
   if (z > 9)
   {
     TCCR0 = 0x00; 
   }    
    
}




void IRQ_init(void){
    cli();                        // Interrupts ein sei() 

    GICR |= (0<<INT0);             // externer INT Disable 
    GICR |= (0<<INT1);

    MCUCR |= (1<<ISC10);        // Einstellen des Auslösers = Seite 67 Datasheet mega 32
    MCUCR |= (1<<ISC11);

    MCUCR |= (1<<ISC00);
    MCUCR |= (1<<ISC01);

    GICR |= (1<<INT0);             // extern INT Enable
    GICR |= (1<<INT1);

    TCNT0 = 0x00;                  //Timer0 mit 0 initialisieren (00000000)
    TIMSK = 0x01;

    sei();                        // Interrupts aus cli()

}







int main(void)
{
    // Pin als Eingang mit Pullup 
    DDRA = (0 << DDA2);                  // Programm 
    DDRD = (0 << DDD2) | (0 << DDD3);    // Interrupts A und B
    PORTA |=  (1<<PA2);
    PORTD |=  (1<<DD2) | (1<<DD3);

    //Timer/Counter Control Register 0
    //CS02, CS01 und CS00: Prescale auf 256
    TCCR0 = (1<<CS02) | (0<<CS01) | (0<<CS00);


//  Digit 1: B0, B1, B2, B3
      DDRB = (1 << DDB0) | (1 << DDB1) | (1 << DDB2) | (1 << DDB3);   
//  Digit 2: C4, C5, C6, C7
//    Digit 3: C0, C1, C2, C3 
     DDRC = (1 << DDC0) | (1 << DDC1) | (1 << DDC2) | (1 << DDC3) | (1 << DDC4) | (1 << DDC5) | (1 << DDC6) | (1 << DDC7);
    DDRD = (1 << DDD5);
    DDRA = (1 << DDA0);

  IRQ_init();
  int a = 0, b = 0, c = 0; 
  short  value = 0; 
  running = 0; 

   PORTA &= ~  (1<<PA0);
   
   while(1)
   {
    digit1(z);
    digit2(y);
    digit3(x); 
  
      while (stopp == 1){
    digit1(z);
    digit2(y);
    digit3(x); 
    _delay_ms(50000);
    
    value = (1.395/(sec/100))  *3.6*10;  //1,394 Länge zwischen S1 und S2 mit 10 für Anzeige 01,0 m/s)  
    
    a = value % 10; 
    value = value / 10;
     
    b = value % 10;
    value = value / 10; 
    
    c = value % 10; 
    
    digit1(c);
    digit2(b);
    digit3(a); 
    _delay_ms(50000);
    }

  }
}
Ansonsten hilft es das Signal direkt am Sensor umzuwandeln in High-Low und dann so zum µC zu übertragen. Man sollte generell die Signal-Wandlung immer so nah wie möglich am Sensor machen und nicht den Sensorwert über die Leitung schicken.