#include #define trig 3 #define echo 4 long distance = 0; long echotime; long timer = 0; int count = 0; //ISR for PCINT20 ISR(PCINT2_vect) { cli(); distance = pulseIn(echo, HIGH); PCICR &= ~0b00000100; PCMSK2 &= ~0b00010000; delayMicroseconds(10); } long calculateDistance(){ return (long) (((float) distance/ 58.0)); } void measureDistance(){ Serial.println("Measuring"); PORTD |= (1<= 100){ measureDistance(); timer = millis(); } Serial.print("Temperatur: "); Serial.println(dallas(2, 0)); Serial.print("Distanz: "); Serial.print(calculateDistance()); Serial.println("cm"); run_time = micros() - run_time; Serial.print("Zeit für Durchlauf: "); Serial.println(run_time); Serial.println(); delay(1000); }