Coder Social home page Coder Social logo

stratus9 / hc-sr04e Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ngourlay/hc-sr04e

0.0 2.0 0.0 1.01 MB

Firmware for the improved HC-SR04E ultrasonic rangefinder by UglyDuck

License: GNU General Public License v2.0

Ruby 3.56% C 62.51% C++ 33.93%

hc-sr04e's Introduction

HC-SR04E

Firmware for the improved HC-SR04E ultrasonic rangefinder by UglyDuck

#Hardware setup for normal use

Connect the HC-SR04E VCC and GND pins to your 5V power supply.

The HC-SR04E uses the I2C bus for communication. What this means is that the sensor's MOSI pin must be connected to the I2C data line (SDA) and the SCK pin must be connected to the I2C clock line (SCL).

The pins used on the Arduino Uno for I2C are the analog input pins A4 (SDA) and A5 (SCL). Other Arduino models use different pins; the following link has a complete list.

http://arduino.cc/en/reference/wire

For other microprocessors, refer to the datasheet. Usually, the I2C pins will be labelled SDA and SCL in the "Pin Configurations" diagrams towards the beginning of the document.

#Hardware setup for programming

If using an Arduino Uno for programming, upload the ArduinoISP sketch before proceeding. Connect the sensor's VCC and GND pins as before, then connect the RESET, MOSI, MISO and SCK pins to pins 10, 11, 12 and 13, respectively, on the Arduino Uno. Bridge the Arduino's RESET and GND pins with a 10uF electrolytic capacitor.

If using another AVR programmer, connect the ICSP header to the sensor's pins as required.

#Software requirements

To compile the source code, you'll need gcc, avr-gcc (and the rest of the toolchain), and avrdude. On Linux, you should be able to install the prerequisites using the following command:

sudo apt-get install binutils-avr avr-libc avrdude gcc-avr

On Windows, you'll need to install WinAVR, Ruby, and the Arduino software package.

Set the environmental variable SERIAL_PORT to point to the USB port connected to your Arduino. On my Linux laptop, this is /dev/ttyACM0, but on your computer it probably be different. The easiest way to find the correct port is by checking in the Arduino IDE, under TOOLS->SERIAL PORT.

export SERIAL_PORT=/dev/ttyACM0

The following command will rebuild the software, run all the unit tests and upload the newly built code to the HC-SR04, via your ArduinoISP:

rake clobber clean test:all program

If you're not using an Arduino as your programmer, you'll probably have to play around with the baud rate and other avrdude arguments in the rakefile.rb file.

hc-sr04e's People

Contributors

ngourlay 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.