24 if(digitalPinToInterrupt(
echoPin) != NOT_AN_INTERRUPT)
26 Serial.println(
"Attaching rangefinder ISR");
31 Serial.println(
"Attaching rangefinder PC_ISR");
36 Serial.println(
"Not a rangefinder interrupt pin!");
72 delayMicroseconds(30);
81 uint16_t echoLength = 0;
96 if(pulseDur)
distance = pulseDur / 58.0;
void ISR_Rangefinder(void)
uint8_t checkPingTimer(void)
checkPingTimer() checks to see if it's time to send a new ping.
Rangefinder(uint8_t echo, uint8_t trig)
Constructor.
float getDistance(void)
Returns the last recorded distance in cm. The first call to getDistance() will return 99.
void ISR_echo(void)
ISR for the echo pin.
volatile uint32_t pulseEnd
volatile uint32_t pulseStart
uint8_t digitalPinToPCInterrupt(uint8_t pin)
void attachPCInt(uint8_t pcInt, void(*pcisr)(void))
Attaches a function to a pin change interrupt.