Skip to content

mikedamage/arduino-libping

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

arduino-libping

A small library for controlling Parallax PING))) Ultrasonic Rangefinders

Version: 0.1

by Mike Green (mike.is.green[at]gmail[dot]com)

Status

The library now successfully compiles in the Arduino IDE. Testing will follow.

Roadmap

  • Add a utility method for calculating the speed of sound at current temperature and elevation. Necessary to calculate distance accurately.
  • Include methods for returning the distance in inches, cm, mm.

Summary

I started writing this library during a bit of a building spree that died off a while ago. I never actually got it working, and it's languished here for quite some time. But I've resolved to get it working.

This library represents my first attempt at writing reusable C++ code, so it's gonna be rough. But its domain is also pretty simple, since the PING))) has an onboard controller that handles all the gritty details of its operation. All this library needs to do is send signals to the attached PING))) and receive its calculations.

Usage

Currently the library supports a single public method: measure(). This method returns the number of microseconds it took for the pulse of sound to bounce back to the PING))) as a long number.

Example

#include "Ping.h"

// Create a Ping instance, connected to digital pin 7
Ping ping(7);

void setup() {
  Serial.begin(9600);
}

// Activate the PING))) once per second and print the measured time to serial console.
void loop() {
  long duration, inches, cm, mm;
  duration = ping.measure();
  Serial.print("Pulse took ");
  Serial.print(duration);
  Serial.println(" microseconds to return.");
  delay(1000);
}

License

This library is released under the terms of the GNU Lesser General Public License. See LICENSE for details.

Enjoy!

Arduino and Parallax PING)))

About

Arduino C++ library for working with the Parallax PING))) Ultrasonic Distance Sensor

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages