This class allows you to get datas from the Parallax PING))) sensor easily in C++!
You have to download and install the pigpio library:
sudo apt-get install pigpio
To start the pigpio daemon run
sudo systemctl start pigpiod
sudo systemctl enable pigpiod
For running the library you can create an example like this:
#include <iostream>
#include <stdio.h>
#include <pigpio.h>
#include "libSonar.h"
using namespace std;
int trigger = 19;
int echo = 26;
int main()
{
if (gpioInitialise() == -1)
return -1;
Sonar sonar;
sonar.init(trigger, echo);
while(1){
cout << "Distance is " << sonar.distance() << " cm." << endl;
}
}