Grove soundsensor lib

Committer:
math991e
Date:
Thu Jan 17 07:42:19 2019 +0000
Revision:
0:18d442efc99a
Child:
1:29daa2bdd0c6
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
math991e 0:18d442efc99a 1 /**
math991e 0:18d442efc99a 2 *#include "mbed.h"
math991e 0:18d442efc99a 3 *#include "soundsensor.h"
math991e 0:18d442efc99a 4 *soundsensor sound(A0);
math991e 0:18d442efc99a 5 *bool toDb = true;
math991e 0:18d442efc99a 6 *
math991e 0:18d442efc99a 7 *int main()
math991e 0:18d442efc99a 8 *{
math991e 0:18d442efc99a 9 * while (true) {
math991e 0:18d442efc99a 10 * printf("Loudness: %f\r\n", sound.listen(toDb));
math991e 0:18d442efc99a 11 * wait(0.5);
math991e 0:18d442efc99a 12 * }
math991e 0:18d442efc99a 13 *}
math991e 0:18d442efc99a 14 **/
math991e 0:18d442efc99a 15
math991e 0:18d442efc99a 16 #ifndef SOUNDSENSOR
math991e 0:18d442efc99a 17 #define SOUNDSENSOR
math991e 0:18d442efc99a 18
math991e 0:18d442efc99a 19 class soundsensor{
math991e 0:18d442efc99a 20 private:
math991e 0:18d442efc99a 21 PinName _pin;
math991e 0:18d442efc99a 22 public:
math991e 0:18d442efc99a 23 soundsensor(PinName);
math991e 0:18d442efc99a 24 void setpin(PinName pin);
math991e 0:18d442efc99a 25 PinName getPin();
math991e 0:18d442efc99a 26 float convertToDb(float);
math991e 0:18d442efc99a 27 float revertFromDb(float);
math991e 0:18d442efc99a 28 float listen(float input, bool toDb);
math991e 0:18d442efc99a 29 }
math991e 0:18d442efc99a 30
math991e 0:18d442efc99a 31 #endif