Skip to content

A simple class for an HC SR04 ultrasonic sensor, primarily for Arduinos.

Notifications You must be signed in to change notification settings

aramperez/HC_SR04

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

HC_SR04

A simple class for an HC SR04 ultrasonic sensor, primarily for use with Arduinos.

Description

HC_SR04( trigPin, echoPin, delay )

Creates an HC_SR04 object (constructor).

Arguments

  • uint8_t trigPin: number of the pin connected to the trigger.
  • uint8_t echoPin: number of the pin where the echo delay comes back on.
  • unsigned long delay: the delay, in milliseconds, to wait for the echo. Default is 1000 ms.

void setDelay( delay )

Sets a new delay for listening for the echo.

Arguments

  • unsigned long delay: delay in milliseconds.

unsigned long inches()

Returns distanced measured by the ultrasonic sensor in inches. If no echo was received in the delay time, then (unsigned long) -1 is returned.

unsigned long centimeters()

Returns distanced measured by the ultrasonic sensor in centimeters. If no echo was received in the delay time, then (unsigned long) -1 is returned.

About

A simple class for an HC SR04 ultrasonic sensor, primarily for Arduinos.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages