Files
projekt-arduino/Sonar.h
T
GarandPLG c053a296a5 Add single‑pin Sonar support with periodic reading
Implemented Sonar constructor to use a single shared pin, added mode
flag and
helper method for single‑pin measurements. Updated measure() to select
the
appropriate implementation and added timeout to pulseIn. Integrated
periodic
sonar updates in the main loop, tracking last update time and toggling a
seatBelts flag based on distance thresholds.
2026-06-17 00:03:17 +02:00

21 lines
289 B
C++

#pragma once
#include <Arduino.h>
class Sonar {
public:
Sonar(int sharedPin, long maxDistCm = 400);
long measure();
long getDistance() const;
private:
int _trigPin;
int _echoPin;
bool _singlePinMode;
long _maxDistCm;
long _lastDistance;
long _measureSinglePin();
};