upm  0.5.1
Sensor/Actuator repository for libmraa (v0.9.1)
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
Public Member Functions | Protected Attributes
Loudness Class Reference

API for the Loudness Sensor. More...

Detailed Description

This sensor family returns an analog voltage proportional to the loudness of the ambient environment. It's output does not correspond to a particular sound level in decibels. The higher the output voltage, the louder the ambient noise level.

This device uses an electret microphone for sound input.

This driver was developed using the DFRobot Loudness Sensor V2 and the Grove Loudness sensor.

groveloudness.jpg
// Instantiate a Loudness sensor on analog pin A0, with an analog
// reference voltage of LOUDNESS_AREF
upm::Loudness *loud = new upm::Loudness(0, LOUDNESS_AREF);
// Every tenth of a second, sample the loudness and output it's
// corresponding analog voltage.
while (shouldRun)
{
cout << "Detected loudness (volts): " << loud->loudness() << endl;
usleep(100000);
}

Public Member Functions

 Loudness (int pin, float aref=5.0)
 
 ~Loudness ()
 
float loudness ()
 

Protected Attributes

mraa::Aio m_aio
 

Constructor & Destructor Documentation

Loudness ( int  pin,
float  aref = 5.0 
)

Loudness constructor

Parameters
pinAnalog pin to use
arefAnalog reference voltage; default is 5.0 V
~Loudness ( )

Loudness destructor

Member Function Documentation

float loudness ( )

Returns the voltage detected on the analog pin

Returns
The detected voltage

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