upm  0.3.1
Sensor/Actuator repository for libmraa (v0.7.2)
Public Member Functions

API for Grove Slide Potentiometer. More...

Detailed Description

Very basic UPM module for Grove slide potentiometer on analog, returns either raw value or scaled voltage value.

upm::GroveSlide* slide = new upm::GroveSlide(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
}
groveslide.jpeg

Public Member Functions

 GroveSlide (unsigned int pin, float ref_voltage=5.0)
 
 ~GroveSlide ()
 
float raw_value ()
 
float voltage_value ()
 
float ref_voltage ()
 
- Public Member Functions inherited from Grove
std::string name ()
 

Additional Inherited Members

- Protected Attributes inherited from Grove
std::string m_name
 

Constructor & Destructor Documentation

GroveSlide ( unsigned int  pin,
float  ref_voltage = 5.0 
)

Grove analog slide potentiometer constructor

Parameters
pinnumber of analog pin to use
ref_voltagethe reference voltage the board is set to as float, e.g. 3.3 or 5.0 (default)

Here is the call graph for this function:

~GroveSlide ( )

GroveSlide Destructor

Member Function Documentation

float raw_value ( )

Get raw value from AIO pin

Returns
the raw value from the ADC

Here is the caller graph for this function:

float voltage_value ( )

Get the voltage value from the pin

Returns
the voltage reading based on the reference voltage

Here is the call graph for this function:

float ref_voltage ( )

Get the board's reference voltage passed on object initialization

Returns
the reference voltage the class was set for

Here is the caller graph for this function:

Inheritance diagram for GroveSlide:
Inheritance graph
[legend]
Collaboration diagram for GroveSlide:
Collaboration graph
[legend]

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