upm  1.3.0
Sensor/Actuator repository for libmraa (v1.7.0)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Member Functions
Slide Class Reference

API for the Slide Potentiometer. More...

Detailed Description

Basic UPM module for the slide potentiometer on analog that returns either a raw value or a scaled voltage value.

upm::Slide* slide = new upm::Slide(0); // Instantiate new grove slide potentiometer on analog pin A0
cout << slide->name() << endl;
while(true) {
float adc_value = slide->raw_value(); // Read raw value
float volts = slide->voltage_value(); // Read voltage, board reference set at 5.0V
fprintf(stdout, "%4d = %.2f V\n", (uint16_t)adc_value, volts);
usleep(2500000); // Sleep for 2.5s

Public Member Functions

 Slide (unsigned int pin, float ref_voltage=5.0)
 ~Slide ()
float raw_value ()
float voltage_value ()
float ref_voltage ()
std::string name ()

Constructor & Destructor Documentation

Slide ( unsigned int  pin,
float  ref_voltage = 5.0 

Analog slide potentiometer constructor

pinNumber of the analog pin to use
ref_voltageReference voltage the board is set to, as a floating-point value; default is 5.0V

Here is the call graph for this function:

~Slide ( )

Slide destructor

Member Function Documentation

float raw_value ( )

Gets the raw value from the AIO pin

Raw value from the ADC

Here is the caller graph for this function:

float voltage_value ( )

Gets the voltage value from the pin

Voltage reading based on the reference voltage

Here is the call graph for this function:

float ref_voltage ( )

Gets the board's reference voltage passed on object initialization

Reference voltage the class was set for

Here is the caller graph for this function:

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