TI RSLK Library 0.2.2
Loading...
Searching...
No Matches
Public Member Functions
GP2Y0A21_Sensor Class Reference

Class for Pololu's Sharp GP2Y0A21YK0F analog distance sensor. More...

#include <GP2Y0A21_Sensor.h>

Public Member Functions

bool begin (uint8_t pin_num, uint8_t mode=INPUT_PULLDOWN)
 Initialize the distance sensor class.
 
uint16_t read ()
 Read the value from distance sensor.
 
int16_t readMM ()
 Read the distance from the Sharp distance sensor in millimeters.
 
float readIN ()
 Read the distance from the Sharp distance sensor in inches.
 

Detailed Description

Class for Pololu's Sharp GP2Y0A21YK0F analog distance sensor.

An instance of this class represents a single [Sharp GP2Y0A21YK0F] (https://www.pololu.com/product/136) distance sensor.

Definition at line 10 of file GP2Y0A21_Sensor.h.

Constructor & Destructor Documentation

◆ GP2Y0A21_Sensor()

GP2Y0A21_Sensor::GP2Y0A21_Sensor ( )

Definition at line 6 of file GP2Y0A21_Sensor.cpp.

Member Function Documentation

◆ begin()

bool GP2Y0A21_Sensor::begin ( uint8_t  pin_num,
uint8_t  mode = INPUT_PULLDOWN 
)

Initialize the distance sensor class.

This function needs to be called before any other function is used.

Parameters
[in]pin_numon Launchpad connected to distance sensor's analog output.
[in]modefor input pin. Options are the same as standard Energia / Arduino pin mode.

Definition at line 11 of file GP2Y0A21_Sensor.cpp.

◆ read()

uint16_t GP2Y0A21_Sensor::read ( )

Read the value from distance sensor.

This function returns a value representing the distance an object is from the sensor.

Returns
Return a value of 0 - 4095. The lower the value the closer an object is.

Definition at line 18 of file GP2Y0A21_Sensor.cpp.

◆ readMM()

int16_t GP2Y0A21_Sensor::readMM ( )

Read the distance from the Sharp distance sensor in millimeters.

This function returns a value representing the distance an object is from the sensor in millimeters. Range is 100 to 800 mm.

Returns
the distance in millimeters (-1 if no object detected)

Definition at line 23 of file GP2Y0A21_Sensor.cpp.

◆ readIN()

float GP2Y0A21_Sensor::readIN ( )

Read the distance from the Sharp distance sensor in inches.

This function returns a value representing the distance an object is from the sensor in inches. Range is ~4 to 31 inches.

Returns
the distance in inches (-1 if no object detected)

Definition at line 38 of file GP2Y0A21_Sensor.cpp.


The documentation for this class was generated from the following files: