TI RSLK Library  0.2.0
Public Member Functions | List of all members
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. More...
 
uint16_t read ()
 Read the value from distance sensor. More...
 

Detailed Description

Class for Pololu's Sharp GP2Y0A21YK0F analog distance sensor.

An instance of this class represents a single Sharp GP2Y0A21YK0F distance sensor.

Definition at line 10 of file GP2Y0A21_Sensor.h.

Member Function Documentation

◆ begin()

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

Initialize the distance sensor class.

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.

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

Definition at line 9 of file GP2Y0A21_Sensor.cpp.

◆ read()

uint16_t GP2Y0A21_Sensor::read ( )

Read the value from distance sensor.

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

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

Definition at line 16 of file GP2Y0A21_Sensor.cpp.


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