hcsr04

package
v0.19.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2021 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package hcsr04 provides a driver for the HC-SR04 ultrasonic distance sensor

Datasheet: https://cdn.sparkfun.com/datasheets/Sensors/Proximity/HCSR04.pdf

Index

Constants

View Source
const TIMEOUT = 23324 // max sensing distance (4m)

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	// contains filtered or unexported fields
}

Device holds the pins

func New

func New(trigger, echo machine.Pin) Device

New returns a new ultrasonic driver given 2 pins

func (*Device) Configure

func (d *Device) Configure()

Configure configures the pins of the Device

func (*Device) ReadDistance

func (d *Device) ReadDistance() int32

ReadDistance returns the distance of the object in mm

func (*Device) ReadPulse

func (d *Device) ReadPulse() int32

ReadPulse returns the time of the pulse (roundtrip) in microseconds

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL