GP2Y0E02B Library¶
gp2y0e02b
¶
Driver for the GP2Y0E02B distance sensor
Author(s): Jose D. Montoya
Implementation Notes¶
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
Adafruit’s Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
- class gp2y0e02b.GP2Y0E02B(i2c_bus: I2C, address: int = _I2C_ADDR)¶
Driver for the GP2Y0E02B Sensor connected over I2C.
- Parameters:
- Raises:
RuntimeError – if the sensor is not found
Quickstart: Importing and using the device
Here is an example of using the
GP2Y0E02B
class. First you will need to import the libraries to use the sensorimport board import gp2y0e02b as GP2Y0E02B
Once this is done you can define your
board.I2C
object and define your sensor objecti2c = board.I2C() # Uses board.SCL and board.SDA gpy = GP2Y0E02B.GP2Y0E02B(i2c)
Now you have access to the attributes
distance = gpy.distance