sensor

package
v0.0.0-...-c5124e8 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Proximity

type Proximity struct {
	Min, Max int // For range checks
	// contains filtered or unexported fields
}

Proximity represents a driver for the QRE1113 proximity sensor, configured as a digital circuit. This operates by setting the pin as an output, charging a capacitor, and then switching the pin to an input and waiting for the capacitor to discharge through the sensor. The faster the discharge time, the stronger the reflected signal.

func NewProximity

func NewProximity(pin *io.Gpio) *Proximity

NewProximity creates and initialises a Proximity struct.

func (*Proximity) Read

func (p *Proximity) Read() (int, error)

Read triggers the sensor by setting the output pin high to charge the capacitor, then turning it off, and detecting how long the capacitor takes to drain. The duration is returned as the number of microseconds.

Jump to

Keyboard shortcuts

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