Coder Social home page Coder Social logo

mirzasky / ultrasonic-1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from makeralchemy/ultrasonic

0.0 1.0 0.0 299 KB

Demonstration program for using a HC-SR05 ultrasonic distance sensor with Python on a Raspberry Pi

License: MIT License

Python 100.00%

ultrasonic-1's Introduction

ultrasonic demonstration program

Overview

ultrasonic.py is a Python program used to demonstrate how to use a HC-SR05 ultrasonic distance sensor on a Raspberry Pi using Python.

ultrasonic.py will run under both Python 2 and Python 3. It was tested on Python 2.7.13 and Python 3.5.3.

Usage Instructions

ultrasonic.py is intended to be executed from the command line.

Command Line Usage:

$ python ultrasonic.py -h

usage: ultrasonic.py [-h] [-a AVERAGED] [-i INDIVIDUAL] [-m MEASUREMENTS]

optional arguments:
  -h, --help            show this help message and exit
  -a AVERAGED, --averaged AVERAGED
                        delay in seconds taking average measurements
  -i INDIVIDUAL, --individual INDIVIDUAL
                        delay in seconds between taking individual
                        measurements
  -m MEASUREMENTS, --measurements MEASUREMENTS
                        number of measurements for averaging

Command Line Examples

Take measurements with the default values: 1 second delay between sets of averaged measurements, 1 measurement per averaged set, 1 second delay between indivual measurements.

 $ python ultrasonic.py

Take measurements with three second delay between sets of averaged measurements, 5 measurements to be averaged, 1/2 second delay between individual measurements.

 $ python ultrasonic.py -a 3.0 -m 5 -i 0.5

 or

 $python ultrasonic.py --averaged 3.0 --measurements 5 --individual 0.5

Sample output

 $ python ultrasonic.py -a 3.0 -m 5 -i 0.5
 Number of measurements in each average:  5
 Delay between individual measurements:  0.5
 Delay between taking the averaged measurements:  3.0
 Ultrasonic Measurement
 Speed of sound is 331.12 m/s at  20 degrees celsius
 Measurement   1, Distance: 168.2
 Measurement   2, Distance: 168.2
 Measurement   3, Distance:  14.6
 Measurement   4, Distance:  13.8
 Measurement   5, Distance:  67.9
 Measurement   6, Distance:  38.1
 Measurement   7, Distance:  20.0
 Measurement   8, Distance:  20.9
 Measurement   9, Distance: 168.8
 ^C
 Keyboard Interrupt!
 $

Installation Instructions

Create a directory for the program:

 mkdir ultrasonic
 cd ultrasonic

Install the monitor code:

 git clone https://github.com/makeralchemy/ultrasonic

After you have the Raspberry Pi setup, run the program:

 python ultrasonic.py

License

This project is licensed under the MIT license.

ultrasonic-1's People

Contributors

makeralchemy avatar

Watchers

 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.