UPM

The UPM API is a high level sensor library for IoT devices using MRAA. See examples here. Back to index page.
SparkFun sensor images provided under CC BY-NC-SA-3.0.

GP2Y0A Class

Module: gp2y0a

Sensors of this family return an analog voltage corresponding to the distance of an object from the sensor. The voltage is lower when objects are far away; the voltage increases as objects get closer to the sensor.
gp2y0a.jpg

Item Index

Methods

Methods

GP2Y0A

(
  • pin
)
Number

GP2Y0A sensor constructor

Parameters:

  • pin Number

    Analog pin to use

Returns:

Number:

value

(
  • aref
  • samples
)
Number

Gets an average voltage value from the sensor

Parameters:

  • aref Number

    Reference voltage in use (usually 5.0V or 3.3V)

  • samples Number

    Number of samples to average over

Returns:

Number:

Average voltage reading