GithubHelp home page GithubHelp logo

cyberflamego / easyultrasonic Goto Github PK

View Code? Open in Web Editor NEW

This project forked from spulbergeorge/easyultrasonic

0.0 2.0 0.0 36 KB

An Arduino library used to work with ultrasonic sensors in an easy way for measuring distance.

License: MIT License

C++ 100.00%

easyultrasonic's Introduction

EasyUltrasonic

  • An Arduino library used to work with ultrasonic sensors in an easy way for measuring distance.

Specifications

  • Works with the HC-SR04 ultrasonic sensor in the 3 Pin Mode/4 Pin Mode, the Ping))) ultrasonic sensor in the 3 Pin Mode and the DHT temperature/humidity sensors for getting precise distance values.

Software Requirements

  • You will need to use at least Arduino IDE 1.0.0 or newer version.

Hardware Requirements

Usage

  • Include the library so you can use it:
#include <EasyUltrasonic.h>
  • Create an EasyUltrasonic object:
EasyUltrasonic ultrasonic;
  • Functions:
attach(uint8_t trigPin, uint8_t echoPin, float minDistance = 2, float maxDistance = 400); // Sets the sensor pins as output/input (The default values for the minDistance and maxDistance parameters correspond to the HC-SR04 ultrasonic sensor distance range)

getDistanceCM(); // Returns the calculated distance in centimeters

getDistanceIN(); // Returns the calculated distance in inches

getPreciseDistanceCM(float temp, float hum); // Calculates an accurate distance by knowing the temperature and humidity of the environment and  returns the calculated distance in centimeters

getPreciseDistanceIN(float temp, float hum); // Calculates an accurate distance by knowing the temperature and humidity of the environment and returns the calculated distance in inches

convertToCM(float distanceValueIN); // Returns the converted value from inches to centimeters

convertToIN(float distaceValueCM); // Returns the converted value from centimeters to inches

Check out the examples folder in the EasyUltrasonic repository to understand more.

Circuit diagrams

3 Pin Mode - Works for the HC-SR04 ultrasonic sensor and the Ping))) ultrasonic sensor -

! If you want to use the HC-SR04 ultrasonic sensor in the 3 Pin Mode you will have to short the trig pin and the echo pin together so you have only one signal pin !
! If you want to use one of the ultrasonic sensors in the 3 Pin Mode, when you call the attach() function you will need to set the trigPin and the echoPin parameters as the same value !
// !!! If you are using the Ping))) ultrasonic sensor, when you call the attach() function you should set the minDistance and maxDistance parameters to the corresponding values by knowing that the Ping))) sensor has a range between 3cm and 300cm:
attach(TRIGPIN, ECHOPIN, 3, 300);
  • Calculating normal distance with the HC-SR04 ultrasonic sensor in the 3 Pin Mode and an Arduino UNO board: HCGetDistance3PinMode

  • Calculating precise distance with the HC-SR04 ultrasonic sensor in the 3 Pin Mode, a DHT temperature/humidity sensor and an Arduino UNO board: HCGetPreciseDistance3PinMode

  • Calculating normal distance with the Ping))) ultrasonic sensor in the 3 Pin Mode and an Arduino UNO board: PingGetDistance3PinMode

  • Calculating precise distance with the Ping))) ultrasonic sensor in the 3 Pin Mode, a DHT temperature/humidity sensor and an Arduino UNO board: PingGetPreciseDistance3PinMode

4 Pin Mode - Works for the HC-SR04 ultrasonic sensor -

  • Calculating normal distance with the HC-SR04 ultrasonic sensor in the 4 Pin Mode and an Arduino UNO board: HCGetDistance4PinMode

  • Calculating precise distance with the HC-SR04 ultrasonic sensor in the 4 Pin Mode, a DHT temperature/humidity sensor and an Arduino UNO board: HCGetPreciseDistance4PinMode

Check out the examples folder in the EasyUltrasonic repository to understand more.

Author

License

MIT

easyultrasonic's People

Contributors

spulbergeorge avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.