29 lines
544 B
C++
29 lines
544 B
C++
#pragma once
|
|
|
|
#include "Sensors/TouchSensor.h"
|
|
|
|
namespace RoboidControl {
|
|
namespace Arduino {
|
|
|
|
class UltrasonicSensor : public TouchSensor {
|
|
public:
|
|
UltrasonicSensor(Participant* participant, unsigned char pinTrigger, unsigned char pinEcho);
|
|
|
|
// parameters
|
|
|
|
float touchDistance = 0.2f;
|
|
|
|
// state
|
|
|
|
float distance = 0;
|
|
float GetDistance();
|
|
|
|
virtual void Update(unsigned long currentTimeMs) override;
|
|
|
|
protected:
|
|
unsigned char pinTrigger = 0;
|
|
unsigned char pinEcho = 0;
|
|
};
|
|
|
|
} // namespace Arduino
|
|
} // namespace RoboidControl
|