Grove soundsensor lib

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers soundsensor.h Source File

soundsensor.h

Go to the documentation of this file.
00001 /**
00002 *
00003 * @file soundsensor.h
00004 * @brief supposed to get analogin and change input to Db, but the logic dont seem to work.
00005 *
00006 * @author Nikolaj M. & Mathias R.
00007 *
00008 * @date 23/1/2019
00009 *
00010 *-----EXAMPLE-----
00011 *#include "mbed.h"
00012 *#include "soundsensor.h"
00013 *soundsensor sound(A0);
00014 *bool toDb = true;
00015 *
00016 *int main()
00017 *{
00018 *    while (true) {
00019 *        printf("Loudness: %f\r\n", sound.listen(toDb));
00020 *        wait(0.5);
00021 *    }
00022 *}
00023 *-----EXAMPLE-----
00024 **/
00025 
00026 //Version mbed: 164
00027 //PROGRAM: SoundSensor
00028 #ifndef SOUNDSENSOR
00029 #define SOUNDSENSOR
00030 #include "mbed.h"
00031 
00032 ///SoundSensor CLASS
00033 class soundsensor{
00034 ///INITIALIZE VARIABLES USED IN CLASS
00035     private:
00036         PinName _pin;
00037 ///FUNCTIONS AND CONSTRUCTOR
00038     public:
00039         soundsensor(PinName);
00040         void setPin(PinName pin);
00041         PinName getPin();
00042         float convertToDb(float);
00043         float revertFromDb(float);
00044         float listen(bool toDb);
00045 };
00046 
00047 #endif