Grove soundsensor lib

soundsensor.h

Committer:
math991e
Date:
2019-01-23
Revision:
9:c38836e5d1f5
Parent:
8:5b4b258eb1da

File content as of revision 9:c38836e5d1f5:

/**
*
* @file soundsensor.h
* @brief supposed to get analogin and change input to Db, but the logic dont seem to work.
*
* @author Nikolaj M. & Mathias R.
*
* @date 23/1/2019
*
*-----EXAMPLE-----
*#include "mbed.h"
*#include "soundsensor.h"
*soundsensor sound(A0);
*bool toDb = true;
*
*int main()
*{
*    while (true) {
*        printf("Loudness: %f\r\n", sound.listen(toDb));
*        wait(0.5);
*    }
*}
*-----EXAMPLE-----
**/

//Version mbed: 164
//PROGRAM: SoundSensor
#ifndef SOUNDSENSOR
#define SOUNDSENSOR
#include "mbed.h"

///SoundSensor CLASS
class soundsensor{
///INITIALIZE VARIABLES USED IN CLASS
    private:
        PinName _pin;
///FUNCTIONS AND CONSTRUCTOR
    public:
        soundsensor(PinName);
        void setPin(PinName pin);
        PinName getPin();
        float convertToDb(float);
        float revertFromDb(float);
        float listen(bool toDb);
};

#endif