Skip to content

This class allows you to get the distance from the HC-SR04 sensor in C++ using the pigpio library.

Notifications You must be signed in to change notification settings

Michdo93/HC-SR04-Raspberry-Pi-C-

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HC-SR04 Raspberry Pi C++

This class allows you to get datas from the Parallax PING))) sensor easily in C++!

Installation

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

Usage

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;
    }
}

About

This class allows you to get the distance from the HC-SR04 sensor in C++ using the pigpio library.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 79.3%
  • Makefile 16.3%
  • Shell 4.4%