All Projects → ErickSimoes → Ultrasonic

ErickSimoes / Ultrasonic

Licence: mit
Minimalist library for Ultrasonic Module HC-SR04, PING))) and Seeed SEN136B5B to Arduino

Projects that are alternatives of or similar to Ultrasonic

Rf24
OSI Layer 2 driver for nRF24L01 on Arduino & Raspberry Pi/Linux Devices
Stars: ✭ 1,813 (+2254.55%)
Mutual labels:  hacktoberfest, arduino, arduino-library
Bh1750
An Arduino library for the digital light sensor breakout boards containing the BH1750FVI IC
Stars: ✭ 173 (+124.68%)
Mutual labels:  arduino, sensor, arduino-library
Rf24network
OSI Layer 3 Networking for nRF24L01(+) Radios on Arduino and Raspberry Pi
Stars: ✭ 278 (+261.04%)
Mutual labels:  hacktoberfest, arduino, arduino-library
Irremoteesp8266
Infrared remote library for ESP8266/ESP32: send and receive infrared signals with multiple protocols. Based on: https://github.com/shirriff/Arduino-IRremote/
Stars: ✭ 1,964 (+2450.65%)
Mutual labels:  hacktoberfest, arduino, arduino-library
Rf24mesh
OSI Layer 7 Mesh Networking for RF24Network & nrf24L01+ devices
Stars: ✭ 329 (+327.27%)
Mutual labels:  hacktoberfest, arduino, arduino-library
Fram mb85rc i2c
Arduino library for I2C FRAM - Fujitsu MB85RC & Cypress FM24, CY15B
Stars: ✭ 41 (-46.75%)
Mutual labels:  arduino, arduino-library
Sslclient
🔒Add SSL/TLS functionality to any Arduino library
Stars: ✭ 45 (-41.56%)
Mutual labels:  arduino, arduino-library
Gem
Good Enough Menu for Arduino
Stars: ✭ 54 (-29.87%)
Mutual labels:  arduino, arduino-library
Tm16xx
Arduino TM16xx library for LED & KEY and LED Matrix modules based on TM1638, TM1637, TM1640 and similar chips. Simply use print() on 7-segment and use Adafruit GFX on matrix.
Stars: ✭ 61 (-20.78%)
Mutual labels:  arduino, arduino-library
Button
An Arduino compatible library to make working with user input easier
Stars: ✭ 27 (-64.94%)
Mutual labels:  arduino, arduino-library
Segacontroller
Arduino library to read Sega Genesis (Mega Drive) and Master System (Mark III) controllers.
Stars: ✭ 55 (-28.57%)
Mutual labels:  arduino, arduino-library
Ws2812fx
WS2812 FX Library for Arduino and ESP8266
Stars: ✭ 1,113 (+1345.45%)
Mutual labels:  arduino, arduino-library
Hydroponic Automation
A program to monitor and control 8 variables of a hydroponic gardening system
Stars: ✭ 38 (-50.65%)
Mutual labels:  arduino, sensor
Kotihome
Home automation system based on Arduino with sensors, Raspberry Pi, Node.js and React
Stars: ✭ 32 (-58.44%)
Mutual labels:  arduino, sensor
Cayennelpp
Library for Arduino compatible with Cayenne Low Power Payload
Stars: ✭ 51 (-33.77%)
Mutual labels:  arduino, arduino-library
Sigmadsp
A versatile Arduino library for interfacing with the ADAU1701 audio DSP
Stars: ✭ 30 (-61.04%)
Mutual labels:  arduino, arduino-library
Esp8266 deauther
Affordable WiFi hacking platform for testing and learning
Stars: ✭ 9,312 (+11993.51%)
Mutual labels:  hacktoberfest, arduino
Micronmea
A compact Arduino library to parse NMEA sentences.
Stars: ✭ 66 (-14.29%)
Mutual labels:  arduino, arduino-library
Dmxusb
DMXUSB emulates an ENTTEC-compatible DMXKing USB to DMX serial device with one, two, or n universes.
Stars: ✭ 66 (-14.29%)
Mutual labels:  arduino, arduino-library
Nintendoextensionctrl
Arduino library for communicating with Nintendo extension controllers
Stars: ✭ 67 (-12.99%)
Mutual labels:  arduino, arduino-library

Open Source badge GitHub GitHub release (latest by date) Arduino Lint

Ultrasonic

Minimalist library for ultrasound module to Arduino

Compatible with HC-SR04, Ping))) and Seeed SEN136B5B (from Seeed Studio)

Work with ultrasonic modules is fairly simple, but can be even more practical if you abstract the control of some features. This library aims to resource efficiency and to simplify access to data.

Where necessary use the ultrasonic module HC-SR04 (one of the most common on the market), Ping))) and/or Seeed SEN136B5B (from Seeed Studio), there are hundreds of libraries that purport to provide the most diverse roles for the user, however, the vast majority of the time, we just need to find out the distance and is that's what does this library.

This library is minimalist, reduces code execution, validation and unnecessary use of global variables, prioritizing smaller data types.

Wiring:

It is very easy to connect an ultrasound module to the Arduino. For example, if you are using HC-SR04, connect the trigger and echo pin module on pin 12 and 13 of the Arduino, respectively. As in the picture: HC-SR04 with Arduino

If you are using a module with three pins (like Ping))) or Seeed SEN136B5B), you can conect the sig pin module on pin 13 of the Arduino.

You can use the Fritzing(.fzz) files inside extras to draw your prototypes.

How to use:

The idea is to provide a simpler environment possible. To do this, simply follow the steps:

  1. Installing

    First you need to import the library so that the IDE recognizes it. The simplest way is importing through the IDE itself:

    • Click in Sketch > Include Library > Manage Libraries...;
    • In the search field type: ultrasonic;
    • In the list, look for Ultrasonic by Erick Simões;
    • Click on Install.

    Alternatively, you can download the library here and import the .zip file into the IDE (see how to import a library here).

  2. Importing on code

    To import the library to your code, just write at the beginning of the code #include <Ultrasonic.h> or, in the Arduino IDE, click in Sketch > Include Library > Ultrasonic (will have the same result).

  3. Starting (the most exciting part)

    Now is simply create a variable of type Ultrasonic passing as parameters two values representing, respectively, the Trig (emitter) and Echo (receiver) pins. Like this:

    Ultrasonic ultrasonic(12, 13);
    

    If you are using a module with three pins (like Ping))) or Seeed SEN136B5B), pass as a parameter only the signal pin. Like this:

    Ultrasonic ultrasonic(13);
    
  4. Discovering the distance

    Having initialized a variable, you can run hers from the method that returns the distance read by module Ultrasonic: read():

    ultrasonic.read()
    
  5. Only this?

    Yes. That's it. By default, the value returned from the function read() is the distance in centimeters.

  6. Seriously?

    You can still do a little more determining the unit of measurement that will be returned (centimeters (CM) or inches (INC)).

    ultrasonic.read()    // distance in CM
    ultrasonic.read(CM)  // distance in CM
    ultrasonic.read(INC) // distance in INC
    

    You can also use more than one ultrasound module:

    ultrasonic ultrasound1(12, 13);
    ultrasonic ultrasound2(10, 11);
    ultrasonic ultrasound3(5);
    
  7. Timeouts

    If there is no object in range, the library will lock-up as it waits for the return pulse. You can change how long to wait by setting a timeout (in microseconds) in the constructor:

    Ultrasonic ultrasonic(12, 13, 40000UL);
    

    Or during runtime:

    ultrasonic.setTimeout(40000UL);
    

    Using a 40ms timeout should give you a maximum range of approximately 6.8m. You may need to adjust this parameter.

See the examples here.

License

Ultrasonic by Erick Simões is licensed under a MIT License. Based on the work of Carl John Nobile available here. Feel free to contact the author on Twitter: @AloErickSimoes

See LICENSE for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].