Grove soundsensor lib

Committer:
math991e
Date:
Thu Jan 17 10:41:12 2019 +0000
Revision:
2:d006df643844
Parent:
1:29daa2bdd0c6
Child:
8:5b4b258eb1da
bug fixing

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 2:d006df643844 16 //Version mbed: 164
math991e 2:d006df643844 17
math991e 0:18d442efc99a 18 #ifndef SOUNDSENSOR
math991e 0:18d442efc99a 19 #define SOUNDSENSOR
math991e 1:29daa2bdd0c6 20 #include "mbed.h"
math991e 0:18d442efc99a 21
math991e 0:18d442efc99a 22 class soundsensor{
math991e 0:18d442efc99a 23 private:
math991e 0:18d442efc99a 24 PinName _pin;
math991e 0:18d442efc99a 25 public:
math991e 0:18d442efc99a 26 soundsensor(PinName);
math991e 1:29daa2bdd0c6 27 void setPin(PinName pin);
math991e 0:18d442efc99a 28 PinName getPin();
math991e 0:18d442efc99a 29 float convertToDb(float);
math991e 0:18d442efc99a 30 float revertFromDb(float);
math991e 1:29daa2bdd0c6 31 float listen(bool toDb);
math991e 1:29daa2bdd0c6 32 };
math991e 0:18d442efc99a 33
math991e 0:18d442efc99a 34 #endif