Roboid Control for C++ 0.4
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Attributes | List of all members
RoboidControl::Arduino::UltrasonicSensor Class Reference

Detailed Description

An HC-SR04 ultrasonic distance sensor.

#include <UltrasonicSensor.h>

Inheritance diagram for RoboidControl::Arduino::UltrasonicSensor:
RoboidControl::Thing

Public Member Functions

 UltrasonicSensor (Configuration config, Thing *parent=Thing::LocalRoot())
 
float GetDistance ()
 erform an ultrasonic 'ping' to determine the distance to the nearest object
 
virtual void Update (bool recursive=false) override
 

Public Attributes

float distance = 0
 The distance at which the object is considered to be touched.
 

Protected Attributes

unsigned char pinTrigger = 0
 The pin number of the trigger signal.
 
unsigned char pinEcho = 0
 The pin number of the echo signal.
 

Member Function Documentation

◆ GetDistance()

float RoboidControl::Arduino::UltrasonicSensor::GetDistance ( )

erform an ultrasonic 'ping' to determine the distance to the nearest object

Returns
the measured distance in meters to the nearest object

◆ Update()

void RoboidControl::Arduino::UltrasonicSensor::Update ( bool  recursive = false)
overridevirtual

Reimplemented from RoboidControl::Thing.

Member Data Documentation

◆ distance

float RoboidControl::Arduino::UltrasonicSensor::distance = 0

The distance at which the object is considered to be touched.

The last read distance